Get a TreeViewNode text?
BlitzMax Forums/MaxGUI Module/Get a TreeViewNode text?
| ||
Hello! Is there a way to get the text of a selected item inside a treeviewnode? (cross platform) I'd like to get the filename from this tree for example Import MaxGui.Drivers Strict Local window:TGadget=CreateWindow("My Window",50,50,240,240,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS) Local treeview:TGadget=CreateTreeView(5,5,ClientWidth(window)-10,ClientHeight(window)-10,window) SetGadgetLayout treeview, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED Local root:TGadget=TreeViewRoot(treeview) Local projects:TGadget=AddTreeViewNode("My Files -> Select a ZIP",root) AddTreeViewNode("file1.zip",projects) AddTreeViewNode("file3.zip",projects) While WaitEvent() Print CurrentEvent.ToString() Select EventID() Case EVENT_GADGETACTION Print "What was the filename again?" Case EVENT_WINDOWCLOSE End End Select Wend Thanks! Grisu |
| ||
Just GadgetText() should do the trick Case EVENT_GADGETACTION Print "What was the filename again?" If EventSource()=treeview Then Print "->"+GadgetText(TGadget(SelectedTreeViewNode(treeview))) End If |
| ||
Perfect! - Thought it was more complicated than this... ;) Danke! Last edited 2011 |
| ||
You can also store the filename in the gadgetextra field and then have the gadget text available for cleaner display (like stripping off the file extension, or the gadget extra could include the full path, etc.) |
| ||
Thanks for the informations. I'm using this in my automatic file updater, so leaving the file extension intact is ok. As the user should be able to track the changes that were made. What I really would like to have is a tooltip that stores the filesize though. |
| ||
What I really would like to have is a tooltip that stores the filesize though. You could update a label showing the filesize of the selected treeview node upon GADGETSELECT event. The filesize could be read than as requested, or stored upfront in the gadgetextra field as ima suggested for the filepath and retrieved from there without an extra disk access. |
| ||
you could also use node selection event to trigger the gadget tooltip for the treeview to be set to the gadgetextra, etc... I forget how tooltips work on treeviews, but there may be some cross platform issues with changing it like that, if I recall correctly I used something like that one and it was fine on mac but a little sketchy on windows... |
| ||
AFAIK no crossplatform tooltips for treeviews. |
| ||
Not sure if showing the fliesize on selection is a good thing? I want to keep the update process as quick as possible. It already takes a while if you need to download all station files. Uploaded the latest internal build here to illustrate what I mean: http://188.165.211.46/~knot/prp/prp_slim.zip (650 KB) [Click "About" -> "Check Updates") I really appreciate comments as I want to keep the app user friendly, slick and pretty... :) Last edited 2011 |