# Create right and left click event on the same Object (Ignition Designer)

**URL:** <https://forum.inductiveautomation.com/t/create-right-and-left-click-event-on-the-same-object-ignition-designer/72475>\
**Category:** Ignition\
**Tags:** vision, ignition81\
**Created:** [April 14, 2023, 7:50pm UTC](https://forum.inductiveautomation.com/t/create-right-and-left-click-event-on-the-same-object-ignition-designer/72475 "2023-04-14T19:50:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nbautomation](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@nbautomation](https://forum.inductiveautomation.com/u/nbautomation)\
**Post date:** [April 14, 2023, 7:50pm UTC](https://forum.inductiveautomation.com/t/create-right-and-left-click-event-on-the-same-object-ignition-designer/72475/1 "2023-04-14T19:50:19Z")

</div>

Hi, I'm trying to open different windows(pop-up) on the same object, but I can not see how to make difference between left click event (Event Handlers/Mouse/mouseClicked) and right click event. I could saw script was generated automatically by the navigation button

```
   # This script was generated automatically by the navigation
   # script builder. You may modify this script, but if you do,
   # you will not be able to use the navigation builder to update
   # this script without overwriting your changes.

   param1 = event.source.parent.indice_motor

   window = system.nav.openWindow('BTN_MOTOR', {'indice_motor' : param1})

```

As you can see, I'm using parameters.  
How can I open different windows on left(default) and right click event?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 14, 2023, 8:25pm UTC](https://forum.inductiveautomation.com/t/create-right-and-left-click-event-on-the-same-object-ignition-designer/72475/2 "2023-04-14T20:25:32Z")

</div>

The `event` object you get will be a MouseEvent. MouseEvent has an [`isPopupTrigger`](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/event/MouseEvent.html#isPopupTrigger()) method, so: `param1 = "abc" if event.isPopupTrigger() else "def`.

---

<div class="post-metadata">

**Author:** ![nbautomation](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@nbautomation](https://forum.inductiveautomation.com/u/nbautomation)\
**Post date:** [April 17, 2023, 7:55pm UTC](https://forum.inductiveautomation.com/t/create-right-and-left-click-event-on-the-same-object-ignition-designer/72475/3 "2023-04-17T19:55:48Z")

</div>

I tried your option but I don't know how to use corretcly, By another hand  
I was learning a little bit about scripting and reading the manual, I can see there are Event Object Properties called Buttons:  
The code for the mouse button that caused this event to fire. The following is a list of constants that can be used in the event to determine which mouse button was pressed.

- `event.BUTTON1` (typically the primary, or left, mouse button)
- `event.BUTTON2` (typically the middle mouse button)
- `event.BUTTON3` (typically the secondary, or right, mouse button).

I tried something 'easy' like this(EventHandlers-\>MousePressed-\>Script editor):

```
if event.BUTTON1:
    system.nav.openWindow('Windowspopup1')
    print('Entered button1')
elif event.BUTTON3:
    system.nav.openWindow('Windowspopup2')
    print('Entered button3')
print('Out if')

```

But When I pressed the right click is still running the first IF 'Button1'2

Can you help me with that? I'm New on scripting and Python

---

<div class="post-metadata">

**Author:** ![nbautomation](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@nbautomation](https://forum.inductiveautomation.com/u/nbautomation)\
**Post date:** [April 17, 2023, 8:44pm UTC](https://forum.inductiveautomation.com/t/create-right-and-left-click-event-on-the-same-object-ignition-designer/72475/4 "2023-04-17T20:44:50Z")

</div>

I was reading a little bit more and I Found my solution, I was missing the value to comparate inside the IF

```
 param1 = event.source.parent.indice_motor

 if event.button == event.BUTTON1 :
     system.nav.openWindow('BTN_MOTOR', {'indice_motor' : param1})
     print('Entered the left clic')
 elif event.button == event.BUTTON3:
      system.nav.openWindow('PARAM_MOTOR', {'ind_motor_table' : param1})
      print('entered right clic')

```

Where 'indice\_motor' and 'ind\_motor\_table' are the Custom parameters for the respective pop up windows
