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

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?

The event object you get will be a MouseEvent. MouseEvent has an isPopupTrigger method, so: param1 = "abc" if event.isPopupTrigger() else "def.

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

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

1 Like