Hey everyone, I got a quick question. Its something I cant seem to figure but I'm sure you guys will know. Is there a way on the tree gadget to retrieve the NAME of the child the user has selected?
For example I'll use a movie library reference....
+Action Movie
|
--- The Fifth Element
|
--- Terminator 2 <- I need the name of this if selected by the user
|
--- The Matrix
Basically how to go about getting the name of a child once the user has selected it is what is stumping me. If it was loaded in through code it wouldn't be a problem but its being loaded into the tree through a text file.
Thanks in advanced for any help!
Tree Gadget Question
-
- User
- Posts: 12
- Joined: Mon Feb 20, 2006 7:17 am
- Location: Lost in CyberSpace
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Based on the example in the help:
Code: Select all
If OpenWindow(0, 0, 0, 355, 180, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
TreeGadget(0, 10, 10, 160, 160) ; TreeGadget standard
TreeGadget(1, 180, 10, 160, 160, #PB_Tree_CheckBoxes|#PB_Tree_NoLines) ; TreeGadget with Checkboxes + NoLines
For ID = 0 To 1
For a = 0 To 10
AddGadgetItem (ID, -1, "Normal Item "+Str(a), 0, 0) ; if you want to add an image, use
AddGadgetItem (ID, -1, "Node "+Str(a), 0, 0) ; ImageID(x) as 4th parameter
AddGadgetItem(ID, -1, "Sub-Item 1", 0, 1) ; These are on the 1st sublevel
AddGadgetItem(ID, -1, "Sub-Item 2", 0, 1)
AddGadgetItem(ID, -1, "Sub-Item 3", 0, 1)
AddGadgetItem(ID, -1, "Sub-Item 4", 0, 1)
AddGadgetItem (ID, -1, "File "+Str(a), 0, 0) ; sublevel 0 again
Next
Next
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 0
Select EventType()
Case #PB_EventType_LeftClick
Pos = GetGadgetState(0)
Debug GetGadgetItemText(0, Pos)
EndSelect
Case 1
Select EventType()
Case #PB_EventType_LeftClick
Pos = GetGadgetState(1)
Debug GetGadgetItemText(1, Pos)
EndSelect
EndSelect
EndSelect
ForEver
EndIf
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

-
- User
- Posts: 12
- Joined: Mon Feb 20, 2006 7:17 am
- Location: Lost in CyberSpace
The eventloop is by me 

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
