# Trigger a mouse click (not on a button)

**URL:** <https://forum.inductiveautomation.com/t/trigger-a-mouse-click-not-on-a-button/18299>\
**Category:** Ignition\
**Created:** [June 5, 2018, 5:12pm UTC](https://forum.inductiveautomation.com/t/trigger-a-mouse-click-not-on-a-button/18299 "2018-06-05T17:12:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aladdinwow](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@aladdinwow](https://forum.inductiveautomation.com/u/aladdinwow)\
**Post date:** [June 5, 2018, 5:12pm UTC](https://forum.inductiveautomation.com/t/trigger-a-mouse-click-not-on-a-button/18299/1 "2018-06-05T17:12:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 5, 2018, 5:36pm UTC](https://forum.inductiveautomation.com/t/trigger-a-mouse-click-not-on-a-button/18299/2 "2018-06-05T17:36:43Z")

</div>

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

> [@Button Events Within Templates](http://forum.inductiveautomation.com/t/button-events-within-templates/14382/17):
>
> Here is how I do it. from java.awt.event import MouseEvent evt = MouseEvent(event.source.parent.parent,event.getID(),event.getWhen(),event.getModifiers(),event.x,event.y,event.clickCount,event.popupTrigger,event.button) event.source.parent.parent.dispatchEvent(evt) We take the originating event, from a label inside the template, and create a new instance of the mouse event, only changing the source. If we do not do this, then event.source will be equal to the triggering component inside the t…

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [June 5, 2018, 5:44pm UTC](https://forum.inductiveautomation.com/t/trigger-a-mouse-click-not-on-a-button/18299/3 "2018-06-05T17:44:19Z")

</div>

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:

```auto
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)
	bot.mousePress(MouseEvent.BUTTON1_MASK)
	bot.mouseRelease(MouseEvent.BUTTON1_MASK)

```

---

<div class="post-metadata">

**Author:** ![aladdinwow](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@aladdinwow](https://forum.inductiveautomation.com/u/aladdinwow)\
**Post date:** [June 5, 2018, 5:55pm UTC](https://forum.inductiveautomation.com/t/trigger-a-mouse-click-not-on-a-button/18299/4 "2018-06-05T17:55:20Z")

</div>

This awesome thanks for the help!

I really need to start looking into java components more 😃
