MaxGUI: Context menu on treeview

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

teamonkey(Posted 2006) [#1]
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?


assari(Posted 2006) [#2]
see this thread, http://www.blitzmax.com/Community/posts.php?topic=56725#630731
hth


SebHoll(Posted 2006) [#3]
You need to create the menu before hand - you don't create it once the event is generated. Have a look at this modified CreateTreeView example that supports right-click.



You then use PopupWindowMenu() to display it once the event is generated.

Seb


teamonkey(Posted 2006) [#4]
@assari: That link appears to be broken for me. I just get "ERROR: Internal Error". :(

...

Ah, got it now. Cheers!


kfprimm(Posted 2006) [#5]
same with me, but that was because he is logged in www.blitzmax.com, im logged into www.blitzbasic.com....nvm