Sub menu

Hello,

I would just like to ask if creating a sub pop up menu possible and how?

Thank You :smiley:

Yes, it is possible through scripting. We have a built-in function, system.gui.createPopupMenu, that will create a popup menu. Usually, people use it for a right click menu but it can be used for multiple purposes.

Here is an example:[code]names = []
funcs = []

names.append(ā€œMenu Item 1ā€)
def doMenuItem1(event):
import system
system.gui.messageBox(ā€œMenu item 1 selectedā€)
funcs.append(doMenuItem1)

menu = system.gui.createPopupMenu(names, funcs)
menu.show(event)[/code]That is for a right click menu that you can put in the mouseReleased event handler. If you want it to popup for a left click on any event do this at the end:menu.show(event, 100, 100)using an x and y.

Here is some more information on the function:

http://www.inductiveautomation.com/support/usermanuals/ignition/system_gui_createpopupmenu.htm

1 Like

I’m a little new at this, why is names and funcs equal to []?

Those lines are just creating new lists (array). Then we can add stuff to the lists through list.append().

Oh I see, I’d like to ask if it’s also possible to add html codes in ignition?

Yes, just add ā€œā€ to the beginning of your strings.

oh ok, i have this html code for this button (shown on the picture). what type of component/tool can i paste it on to be able to view that button onto the ignition window?

You can use a button or a label component. Just set the text to your html string. It must start with .

This ā€œmenu.show(event, x, y)ā€ part should definitely be added into the documentation… there is no mention that you can use this function for left click actions anywhere!

Just FYI to anyone else who finds this here and is also confused as I was: the x and y are mouse coordinate offsets from the coordinates of the origin of the object that triggered the popup script.