This thread reminded me that I don’t understand how actions work with mouse clicks. I remember that it has something to do with the event object.
How can I write a script that distinguishes between a left click, right click, or double click?
This thread reminded me that I don’t understand how actions work with mouse clicks. I remember that it has something to do with the event object.
How can I write a script that distinguishes between a left click, right click, or double click?
You’re right. It detecting different clicks is done in Jython with the event object. The reference is located here
This script would run on double-click of the main mouse button
if event.clickCount == 2 and event.button == event.BUTTON1:
fpmi.gui.messageBox("You double clicked this component with the left button.")
This script would run on a right-click of the main mouse button
if event.button == event.BUTTON2:
fpmi.gui.messageBox("You right clicked this component.")
From the help file reference event object constants include:
NOBUTTON - Indicates no mouse buttons were involved in this event.
BUTTON1 - Indicates mouse button #1 (typically left click).
BUTTON2 - Indicates mouse button #2 (typically middle click).
BUTTON3 - Indicates mouse button #3 (typically right click).
event object properties include:
source - The source component for this event.
button - The code for the button that caused this event to fire.
clickCount - The number of mouse clicks associated with this event.
x - The x-coordinate (with respect to the source component) of this mouse event.
y - The y-coordinate (with respect to the source component) of this mouse event.
popupTrigger - Returns True (1) if this mouse event is a popup trigger. What constitutes a popup trigger is operating system dependent, which is why this abstraction exists.
altDown - True (1) if the Alt key was held down during this event, false (0) otherwise.
controlDown - True (1) if the Control key was held down during this event, false (0) otherwise.
shiftDown - True (1) if the Shift key was held down during this event, false (0) otherwise.
You typically put events in whatever interests you, often MousePressed and MouseReleased, then use Jython do determine what specific clicks came in, and write your script accordingly.