Ok, this one has got to be stupid but can anyone tell me why the code below is not working. I have reduced it to a simple test…it is not throwing any error, but it is also not displaying a popupMenu.

app.nav script

[code]def opAdminPopup():
import system, app

def swapArea():
	system.nav.swapTo('App Selection')
	openwin = system.gui.getOpenedWindowNames()
	for win in openwin:
		if '/' in win:

adminPopup = system.gui.createPopupMenu(["Swap Process Area"],[swapArea])
return adminPopup[/code]

mousePressed and mouseReleased on a button

menu = app.nav.opAdminPopup() menu.show()

Thanks for the help. I have been staring at the code for hours and I am not seeing it. If it is something really stupid please go easy on me :slight_smile:

Hi Wes,

I think you’re forgetting to pass in the event reference. Your script code should be:[code]def opAdminPopup():
import system, app

def swapArea(event):
system.nav.swapTo(‘App Selection’)
openwin = system.gui.getOpenedWindowNames()
for win in openwin:
if ‘/’ in win:

adminPopup = system.gui.createPopupMenu([“Swap Process Area”],[swapArea])
return adminPopup[/code]and the code in mousePressed and mouseReleased should be menu = app.nav.opAdminPopup() menu.show(event)

I had previously tried the script with the event passing as you showed Al and it didn’t work either. I just added the event pass back in and still nothing. It’s odd, I have added debug print statements and I know I am getting to the return statement in opAdminPopup but no popupMenu. :frowning:

I tried creating a new window (containing just a label) and script module using your code and it works :scratch:

The only change I made was to comment out the code inside swapArea and instead put a print statement. This prints correctly every time I right-click the label and choose the ‘Swap Process Area’ option.

Maybe try it in a new window in case something hanging around from before is causing the problem.

This is goofy and it still won’t work. I just recoded a test popup (code below) and still no popup menu. I am getting the “Returning from testpopUp” in output console so I know I am getting in but thats about it.

In case it matters my dev machine is:

Win7 64 Bit
Ignition 7.5.5
Java 7

Here is my app script

[code]def testPopup():
import system, app
def printLabel(event):
print ‘here is my label’

popUp = system.gui.createPopupMenu(['print label'],[printLabel])
print "Returning from testpopUp"
return popUp[/code]

Here is my mouse pressed and mouse released

menu = app.nav.testPopup() menu.show(event)


I set up a test window with both sets of your code and both worked without issue using the RIGHT mouse click on a button and label component. I could see the message in the console on LEFT click, but no menu on either.

Try adding this to the mousePressed and mouseReleased events

menu = app.nav.testPopup()
menu.show(event, event.x, event.y)


Adding the event.x, event.y solved the problem for a left click (or touch push). This particular app will primarily be run on touch screens so I wasn’t even thinking about the right mouse click. My original code works fine with a right mouse click incidentally. It make sense (from a windows pop-up perspective) that this popup menu would fire from a right click but I didn’t see anything regarding this in the documentation. Anyways it’s working now and I thank you both (Al and Matlock) for your help. Incidentally nice work on the first post Matlock :smiley:

Good catch hmatlock! Glad you got it working.

Thanks! Glad you have it working now. I incidentally had the same issue a couple of weeks ago when I was also working on a touch centric app and needed a drop down menu from a button, which you can create using the same approach, just replace the x and y portion.

menu = app.nav.testPopup()
menu.show(event, 0, event.source.getHeight())