Mouse Events using event.button1 and actionPerformed

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?

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

1 Like

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

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)?

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.