After looking a bit deeper into the win32maxguiex file i noticed that the treeview allows Drag and Drop of Treenodes. So I've tested it and it works like charm.
' createtreeview.bmx
Import Maxgui.Drivers
Strict
Local window:TGadget=CreateWindow("My Window",50,50,490,240,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS)
Local treeview:TGadget=CreateTreeView(5,5,ClientWidth(window)-250,ClientHeight(window)-10,window,TREEVIEW_DRAGNDROP)
Local textarea:TGadget=CreateTextArea(5 + ClientWidth(window)-250,5,240,ClientHeight(window)-10,window)
SetGadgetLayout treeview, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED
Local root:TGadget=TreeViewRoot(treeview)
Local help:TGadget=AddTreeViewNode("Help",root)
AddTreeViewNode "Topic 1",help
AddTreeViewNode "Topic 2",help
AddTreeViewNode "Topic 3",help
Local projects:TGadget=AddTreeViewNode("Projects",root)
AddTreeViewNode("Sub Project",AddTreeViewNode("Project 1",projects))
AddTreeViewNode("Project 2",projects)
AddTreeViewNode("Project 3",projects)
Global DropItem:TGadget = Null
While WaitEvent()
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_GADGETDRAG
Dropitem:TGadget = TGadget.dragGadget[EventData() - 1]
If DropItem <> Null Then
AddTextAreaText(textarea , "Start Dragging: " + GadgetText(Dropitem) + "~n")
SelectTreeViewNode DropItem
Endif
Case EVENT_GADGETDROP
If DropItem <> Null Then
AddTextAreaText(textarea , "Dropping: " + GadgetText(Dropitem) + "~n")
DropItem = Null
End if
End Select
Wend
Thats a very nice addition and i think this will be useful too many people. thx for adding this :)
|