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

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

Hi!

I am having troubles understanding the difference between eventSource, eventId, EventData and EventExtra.

What I am currently doing is using WaitEvent and then Case EVENT_GADGETSELECT to capture events for my treeview in the application.
But, then I'd like to get the object returned that represents a node in this tree.
This way, I can add another treenode with as parent the object I got returned.

Could someone explain how I can achieve this, and why some examples use eventID's instead of sources? I am confused.

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.

Thank you Klepto2! I will study it!