I want to determine mouseclick orders for buttons, like:
first click → on (conditions are true),
second click → off,
third click - >on,
…
and it goes like this. But I could not figure a way to do this.
I want to determine mouseclick orders for buttons, like:
first click → on (conditions are true),
second click → off,
third click - >on,
…
and it goes like this. But I could not figure a way to do this.
if button is on
off
and vice versa
Haha @Chrisir this might be your best comment yet.
@seym, try
buttonPressed = !buttonPressed;
println("Button is pressed: "+buttonPressed)
…inside the function called whenever you release the button?
?
To be fair, it can get confusing I think he might be struggling with mouse up and mouse down issues. I had this problem when working on my Gui lib, booleans aren’t that straightforward for some people.
Ie
If(mousePressed) mdown =true;
If(mdown)bool1 = true;
If(bool2) bool3= true;
This will result in all bools being set to true on mousedown however maybe the other bools should only be verified after mouse up etc etc.
So then you need to do
If(mousePressed) mdown
If(mdown&&! MousePressed) bool1 =true.
Etc etc
Or perhaps bool1 should only be set, on mouseup followed by a second mouse press. In which case bool1 should then be used to set your second bool instead.
Then you need to consider
If(! MousePressed) mdown =false
This would invalidate your entire logic so you need another bool to evaluate that condition.