MaxGUI: Context menu on treeview

BlitzMax Forums/BlitzMax Beginners Area/MaxGUI: Context menu on treeview

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Is it possible to right-click on a tree node and get a contextual menu?

I've got...
	WaitEvent()
	
	Select EventID()
		Case EVENT_GADGETMENU
			Select EventSource()
				Case tree
					Local popupmenu:TGadget = CreateMenu("popup_tree", 0, tree)
					CreateMenu("Add...", POPUPMENU_ADD, popupmenu)
					CreateMenu("Remove", POPUPMENU_REMOVE, popupmenu)
					PopupWindowMenu(tree, popupmenu)
			EndSelect
		
		Case EVENT_MENUACTION
			Select EventData()					
				Case POPUPMENU_ADD
					Local current_node:TGadget = SelectedTreeViewNode(tree)
					AddTreeViewNode("Added", current_node)
				
				Case POPUPMENU_REMOVE
					Local current_node:TGadget = SelectedTreeViewNode(tree)
					FreeTreeViewNode(current_node)
			End Select


I want to be able to right-click on a node to Add a new branch to the tree or remove a node (and hence all the branches derived from it), but it doesn't seem to work as expected. What am I doing wrong?