# Create popup menu with 2 levels

**URL:** <https://forum.inductiveautomation.com/t/create-popup-menu-with-2-levels/8956>\
**Category:** Ignition\
**Created:** [August 26, 2014, 12:40pm UTC](https://forum.inductiveautomation.com/t/create-popup-menu-with-2-levels/8956 "2014-08-26T12:40:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [August 26, 2014, 12:40pm UTC](https://forum.inductiveautomation.com/t/create-popup-menu-with-2-levels/8956/1 "2014-08-26T12:40:43Z")

</div>

I would like to create popup menu with 2 levels :  
– Command1  
– Command11  
– Command12  
– Command2  
– Command21  
– Command22

Command11  
Command12  
become visible when Command1 is selected

is it possible with system.gui.createPopupMenu ?

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [August 26, 2014, 1:42pm UTC](https://forum.inductiveautomation.com/t/create-popup-menu-with-2-levels/8956/2 "2014-08-26T13:42:48Z")

</div>

Here’s an example that replaces the first menu with a new menu when you select one of its items:

Use in mouseReleased of a label (right-click to activate):

```auto
def subMenu(event):
	import system
	
	def sayHello(event):
		import system
		system.gui.messageBox("Hello World")
	def sayGoodbye(event):
		import system
		system.gui.messageBox("Goodbye Cruel World")
	submenu = system.gui.createPopupMenu({"Hello":sayHello, "Goodbye":sayGoodbye})
	submenu.show(event)
menu = system.gui.createPopupMenu({"SUB MENU":subMenu})
menu.show(event)

```

---

<div class="post-metadata">

**Author:** ![CPowell](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CPowell](https://forum.inductiveautomation.com/u/CPowell)\
**Post date:** [August 26, 2014, 2:29pm UTC](https://forum.inductiveautomation.com/t/create-popup-menu-with-2-levels/8956/3 "2014-08-26T14:29:52Z")

</div>

Here is another way to do the same thing, just shows previous levels.

```auto
if event.popupTrigger:
       # Create the main menu
	names = []
	funcs = []
	
	##############################################################
	# Create the first sub menu
	subnames = []
	subfuncs = []
	
	##############################################################
	# Add some functions to this menu
	def sayHello(event):
		import system
		system.gui.messageBox("Hello World")
	subnames.append("Hello")
	subfuncs.append(sayHello)
	
	def sayGoodbye(event):
		import system
		system.gui.messageBox("Goodbye Cruel World")
	subnames.append("Goodbye")
	subfuncs.append(sayGoodbye)
	
	##############################################################
	# create English sub menu
	names.append("English")
	funcs.append([subnames,subfuncs])
	
	
	# Add a seperator
	names.append(None)
	funcs.append(None)
	
	##############################################################
	# Create another sub menu
	subnames = []
	subfuncs = []
	
	##############################################################
	# Add functions to this submenu
	def sayHello(event):
		import system
		system.gui.messageBox("Guten Tag")
	subnames.append("Guten Tag")
	subfuncs.append(sayHello)
	
	def sayGoodbye(event):
		import system
		system.gui.messageBox("Guten Abend")
	subnames.append("Guten Abend")
	subfuncs.append(sayGoodbye)
	
	names.append("German")
	funcs.append([subnames,subfuncs])

	##############################################################
	# create the popup menu
	menu = system.gui.createPopupMenu(names, funcs)
	menu.show(event)

```

Cheers,  
Chris
