createPopupMenu only showing on right click?

Here is my overall objective - a user selects a row in a table. Some rows only have parent Id, some have a parent and associated child id.

After the row is selected if they press a button next to the table, if the row only has a parent Id, it just opens a window and passes the single Id parameter. If the row has both, I want a popup menu to appear, asking the user if they want to open the window based on the parent Id or the child Id.

I’ve tried putting this code in a label mouse event onPress and onRelease

ds = event.source.parent.getComponent('Table_SalesOrders').data
selRow = event.source.parent.getComponent('Table_SalesOrders').selectedRow
soId = ds.getValueAt(selRow, "idx")
invId = -1

if event.source.parent.getComponent('TabStrip_SalesOrders').selectedTab == "Status":
	# Then open the help desk thread associated with the sales order only
	print "In status menu"
	pass
else:
	# Give an option, if applicable - do you want to open the sales order, or invoice help desk thread? via popup
	print "In billing menu"
	invNum = ds.getValueAt(selRow, "invNumber")
	print "invNum IS : " + str(invNum)
	invId = system.db.runScalarQuery("SELECT IFNULL(idx, -1) FROM listinvoices WHERE number='%s'"%(invNum))
	print "invId IS : " + str(invId)
	def goToSOHelpDeskThread(event):
		pass
	def goToInvHelpDeskThread(event):
		pass
	print "about to open popup"
	menu = system.gui.createPopupMenu(["Sales Order Help Desk Thread", "Invoice Help Desk Thread"],[goToSOHelpDeskThread,goToInvHelpDeskThread])
	menu.show(event)

just to make sure it would work in concept. It’s odd, when I left click the label, I do see the print “about to open popup” but nothing happens. However, right clicking it does make the popup appear. Right now this code is in the event onRelease. Anyone know how I can make the popup appear on left click as well? Using Ignition 7.9.1.

I figured it out. In the documentation, theres a comment about this - https://docs.inductiveautomation.com/display/DOC/system.gui.createPopupMenu

If you give menu.show an (x,y) coordinate it will show up on both left and right clicks.

menu.show(event, x, y)

So changing it to menu.show(event, event.x, event.y) made it work as intended.

5 Likes