treeview problem
BlitzMax Forums/BlitzMax Programming/treeview problem
| ||
| 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 |
| ||
| sorry for loosing code indentation in the code example I posted before someone can help? Thanks Allos |
| ||
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 |
| ||
| try Node.getText() instead of Node.context |
| ||
| thank you Diablo, but I obtain a compiler error: identifier "name" not found |
| ||
| Dreamora, running code with Node.getText() doesn't work for me Thank you |
| ||
| TGadget.name is new in 1.18. Used to be TGadget.text :) |
| ||
| 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) |
| ||
| 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 |
| ||
| Thats why I use blide. There you get those informations (or possibilities) listed straight after putting the "." in the code. |