Trigger a mouse click (not on a button)

Is there a way to actually trigger a mouse click that is not associated with a button?

For example, in a tree view object, i want a user to be able to right click on an item inside the tree view object and it will act the same way if they have pressed the left click instead, basically to select an item in tree view that they are on.

something like click(event.x, event.y)

I looked in the common functions, but I can’t seem to find anything like this. (also searched in this forum)

Is there such ability in ignition currently?

You can create a mouse event from scratch, copying the relevant information from the original event. Something like this, but dispatched on event.source:

I attempted this but couldn’t get the mask right… Chickened out and just used Robot to emit the new click.

In the mouseClicked event of your TreeView:

from java.awt.event import MouseEvent
from java.awt import Robot

if SwingUtilities.isRightMouseButton(event):
	bot = Robot()
	point = event.getLocationOnScreen()
	bot.mouseMove(point.x, point.y)
1 Like

This awesome thanks for the help!

I really need to start looking into java components more :smiley: