# Is it possible to determine a mouseclick order for buttons

**URL:** https://discourse.processing.org/t/is-it-possible-to-determine-a-mouseclick-order-for-buttons/32254
**Category:** Coding Questions
**Created:** [September 14, 2021, 2:29pm UTC](https://discourse.processing.org/t/is-it-possible-to-determine-a-mouseclick-order-for-buttons/32254 "2021-09-14T14:29:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![seym](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@seym](https://discourse.processing.org/u/seym)
#### Post date: [September 14, 2021, 2:29pm UTC](https://discourse.processing.org/t/is-it-possible-to-determine-a-mouseclick-order-for-buttons/32254/1 "2021-09-14T14:29:55Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [September 14, 2021, 2:56pm UTC](https://discourse.processing.org/t/is-it-possible-to-determine-a-mouseclick-order-for-buttons/32254/2 "2021-09-14T14:56:41Z")

</div>

if button is on  
off

and vice versa

---

<div class="post-metadata">

### Author: ![rapatski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rapatski/32/5164_2.png) [@rapatski](https://discourse.processing.org/u/rapatski)
#### Post date: [September 14, 2021, 8:07pm UTC](https://discourse.processing.org/t/is-it-possible-to-determine-a-mouseclick-order-for-buttons/32254/3 "2021-09-14T20:07:59Z")

</div>

Haha @Chrisir this might be your best comment yet. 😉

@seym, try

```auto
buttonPressed = !buttonPressed;
println("Button is pressed: "+buttonPressed)

```

…inside the function called whenever you release the button?  
?

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [September 14, 2021, 10:36pm UTC](https://discourse.processing.org/t/is-it-possible-to-determine-a-mouseclick-order-for-buttons/32254/4 "2021-09-14T22:36:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [September 14, 2021, 10:41pm UTC](https://discourse.processing.org/t/is-it-possible-to-determine-a-mouseclick-order-for-buttons/32254/5 "2021-09-14T22:41:05Z")

</div>

Ie

```auto
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

```auto
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.
