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.
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