Detect double click inside class

ok, thanks, but that was not the help for the event question.

and a own event handler for the class would be the long way,
but just take a look how the PRO’s are doing it
Text input for choosing Colour .
a ( reduced ) G4P example

but here we try in small steps:


lets start again from the functional side:

as a electrician i know the difference between a

  • push button
  • switch

but here in coding what we actually have?
the button class acts like a switch,
when click mouse LEFT, the switch goes from OFF to ON.
( because it has a latching memory .sel )

if we write some code in main
( continuously polling )
bad style
if ( button[17].sel ) {}
better class code
if ( button[17].get_sel() ) {}
we can do what we need to do, and
then a
button[17].reset();
so we not see the ( .sel == true ) again in the next loop.

in other words from main we converted the switch to a push button
( might not even see the green fill color )
that is also a correct event thinking.


but if we want / need the switch as a switch
we want following 3 information:
-1- event ( click ) OFF to ON
-2- status ON or OFF
-3- event ( click ) ON to OFF
this we can do if we compare the .sel status while polling
with a memory variable in main ( last_sel = …sel;)
easy but kind of ugly,

assuming that via draw and button display the codes are synchronized
it might be enough to have 2 add event bits in the class.

  • .rise
  • .fall

what will be true only for one cycle.
in case of asynchronous operation we must make them latching until read || reset.


in this case with .sel and .seld it is a little bit more complicated.

so…
what you need ( on double click )

  • push button ?
  • switch ?

thinking.