Win32 Hidden feature (Drag&Drop)

BlitzMax Forums/MaxGUI Module/Win32 Hidden feature (Drag&Drop)

klepto2(Posted 2009) [#1]
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 :)


Mark Tiffany(Posted 2009) [#2]
I'd love drag and drop tabs.


jsp(Posted 2009) [#3]
I saw this once, but didn't realize it was already working. Thanks a lot for pointing this out!
Very useful.


Zakk(Posted 2009) [#4]
Awesome, just what I was looking for. Thanks for sharing!
Now I just gotta figure out how to determine where the user dropped it...