# Mouse Events using event.button1 and actionPerformed

**URL:** <https://forum.inductiveautomation.com/t/mouse-events-using-event-button1-and-actionperformed/66849>\
**Category:** Ignition\
**Created:** [November 23, 2022, 1:00pm UTC](https://forum.inductiveautomation.com/t/mouse-events-using-event-button1-and-actionperformed/66849 "2022-11-23T13:00:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 23, 2022, 1:00pm UTC](https://forum.inductiveautomation.com/t/mouse-events-using-event-button1-and-actionperformed/66849/1 "2022-11-23T13:00:13Z")

</div>

I have a confirmation dialog that uses a button. The button's event handler is **mousePressed** , which isn't terribly reliable when the operator is moving the cursor slightly at the same time as clicking.

My solution was to move the code in **actionPerformed** instead.

Since event.BUTTON1 isn't recognized in actionPerformed, how do I make sure that the script is only executed with the left mouse click?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 23, 2022, 2:51pm UTC](https://forum.inductiveautomation.com/t/mouse-events-using-event-button1-and-actionperformed/66849/2 "2022-11-23T14:51:44Z")

</div>

pretty sure actionPerformed only triggers on left clicks (or touch)

---

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 23, 2022, 3:18pm UTC](https://forum.inductiveautomation.com/t/mouse-events-using-event-button1-and-actionperformed/66849/3 "2022-11-23T15:18:09Z")

</div>

Thanks,  
There must be some underlying code in the parent that acts on any mouse press then. I'll look into it.

---

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 23, 2022, 4:58pm UTC](https://forum.inductiveautomation.com/t/mouse-events-using-event-button1-and-actionperformed/66849/4 "2022-11-23T16:58:08Z")

</div>

So digging deeper, it looks like the control value is my issue.

I have a momentary button that has its control value linked to an OPC tag. It appears that the button will toggle the OPC value when either mouse button is pressed.

Is there a way to limit the control value changes to only the left mouse click (not the right)?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [November 23, 2022, 5:11pm UTC](https://forum.inductiveautomation.com/t/mouse-events-using-event-button1-and-actionperformed/66849/5 "2022-11-23T17:11:24Z")

</div>

> [@hmiCanuck](#):
>
> It appears that the button will toggle the OPC value when either mouse button is pressed.

This appears to be the case, which is interesting. I wouldn't expect it to behave that way either.

I would guess the only work around would be to not bind the control value, but instead write to it from the mouse pressed, mouse released scripts using `system.tag.writeBlocking()`

NOTE: Obligatory Momentary Buttons should absolutely not be used for equipment control.
