event...ID,source,data,Extra...confusement

BlitzMax Forums/BlitzMax Beginners Area/event...ID,source,data,Extra...confusement

Type TTest
	Field Name:String
End Type


Global window:TGadget = CreateWindow("Tree Test",200,200,210,420)

Global Tree_View:Tgadget = CreateTreeView(5,5,200,200,Window)
Global Text:TGadget = CreateTextArea(5,205,200,200,Window)

Tree_View.Text = "Tree"

Global Root:TGadget = TreeViewRoot(Tree_View)
Root.Text = "Root"

		
For Local X:Int = 0 To 10		
T1:TGadget = AddTreeViewNode("Root"+X,Root)
Local T:TTest = New TTest
T.Name = "Root"+X
T1.Context = T

For Local Y:Int = 0 To 10 
	T2:TGadget = AddTreeViewNode("Test"+Y,T1)
	T:TTest = New TTest
	T.Name = "Test"+Y
	T2.Context = T

Next
Next


While True
	WaitEvent 
	Print CurrentEvent.ToString()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
		Case Event_GadgetSelect
			Local Tree:TGadget = TGadget(EventSource())
			If Tree <> Null Then
				If  SelectedTreeViewNode(Tree) <> Null Then 
					Local Node:Tgadget = SelectedTreeViewNode(Tree)
					Local NAme:String = TTest(NOde.Context).name
					AddTextAreaText(Text,Name+"~n")
					Print Name
				EndIf
			EndIf
			
			Tree = Null
			
		End Select
Wend


You have to assign an Object to the TGadget.Context to get the Object in Runtime.

I hope the Example shows you how to do it.