[MaxGUI] How to swap TreeView-Nodes

BlitzMax Forums/BlitzMax Beginners Area/[MaxGUI] How to swap TreeView-Nodes

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.

Here is more complex one, (but maybe easier to follow ;)
It Swaps currently the whole Node which is given to the Swap Function in this case the RootNode.

SuperStrict

Local Main:TGadget = CreateWindow("Main" , 20 , 20 , 400 , 400)
Local Tree:TGadget = CreateTreeView(10 , 10 , 360 , 250 , MAin)
Local SwapButton:TGadget = CreateButton("SWAP" , 160 , 260 , 40 , 40 , Main)
Local Root:TGadget = TreeViewRoot(Tree)
For Local Index:Int = 0 To 99
	AddTreeViewNode(Index , Root)
Next



While WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_GADGETACTION
			Select EventSource() 
				Case SwapButton
					Swap(Root)
					Print "Swapped"
				'	RedrawGadget(Tree)
			End Select
		
	End Select
Wend

Function Swap(Node:TGadget)
	ReverseList(Node.Kids)
	Local List:Object[] = Node.Kids.toArray()	
	For Local TempNOde:TGadget = EachIn Node.Kids
		TempNode.Free()
	Next
	For Local TempNode:TGadget = EachIn List
		AddTreeViewNode(TempNode.Name,Node)
	Next
	
End Function