treeview problem

BlitzMax Forums/BlitzMax Programming/treeview problem

allos(Posted 2006) [#1]
I need to return a string from a treeview gadget node, after expandig/collapsing tree
Here is the code I'm having problems (i would like the string to appear for instance in the textfield gadget):

' EXAMPLE CODE
Strict

Local win:TGadget=CreateWindow("My win",50,50,240,340)
Local txt:TGadget=CreateTextField(10, 240, 180,20,win)
Local treeview:TGadget=CreateTreeView(0,0,200,200,win)

SetGadgetLayout treeview,2,2,2,2

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 "project 1",projects
AddTreeViewNode("project 2",projects)
AddTreeViewNode("project 3 is a big waste of time",projects)

Repeat
WaitEvent()
'Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_GADGETACTION
Local Node:TGadget = SelectedTreeViewNode(treeview)
Local s:String=String(Node.Context)
If s > ""
'SetStatusText(win,s)
SetGadgetText(txt,s)
End If
ExpandTreeViewNode(Node)
End Select
Forever
End


allos(Posted 2006) [#2]
sorry for loosing code indentation in the code example I posted before
someone can help?

Thanks
Allos


Diablo(Posted 2006) [#3]
try this:
' EXAMPLE CODE
Strict 

Local win:TGadget=CreateWindow("My win",50,50,240,340)
Local txt:TGadget=CreateTextField(10, 240, 180,20,win)
Local treeview:TGadget=CreateTreeView(0,0,200,200,win)

SetGadgetLayout treeview,2,2,2,2

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 "project 1",projects
AddTreeViewNode("project 2",projects)
AddTreeViewNode("project 3 is a big waste of time",projects)

Repeat
WaitEvent()
'Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_GADGETSELECT
Local Node:TGadget = SelectedTreeViewNode(treeview)
Local s:String=String(node.name)
If s > ""
'SetStatusText(win,s)
SetGadgetText(txt,s)
End If 
ExpandTreeViewNode(Node)
End Select
Forever 
End 



changed to EVENT_GADGETSELECT and node.context to node.name


Dreamora(Posted 2006) [#4]
try Node.getText() instead of Node.context


allos(Posted 2006) [#5]
thank you Diablo, but I obtain a compiler error: identifier "name" not found


allos(Posted 2006) [#6]
Dreamora, running code with Node.getText() doesn't work for me
Thank you


ozak(Posted 2006) [#7]
TGadget.name is new in 1.18. Used to be TGadget.text :)


Dreamora(Posted 2006) [#8]
Hmm tested above code with .getText so I assume you use an outdated version of BM then? (with an outdated version of maxgui then as well)


allos(Posted 2006) [#9]
ok, ozak and dreamora, I think both of you are right
ozak tip makes my code working and so I think I am using an outdated maxgui version
I need to update and, yes, a better documentation is needed, but anyway BlitzMax is a great software
thank you

Allos


Dreamora(Posted 2006) [#10]
Thats why I use blide. There you get those informations (or possibilities) listed straight after putting the "." in the code.