Listbox Help
BlitzMax Forums/MaxGUI Module/Listbox Help
| ||
| Hi. Finally got around to having enough time to give BMax a shot, despite owning it since release. I'm trying to create a listbox that is linked to a list of objects. I notice that there is an 'extra' object field in the AddGadgetItem command. Can I use this to store a pointer to the connected object in my list of objects, and if so, how can I retrieve that pointer when I select one of the items in my listbox? Hope this makes sense. TIA. |
| ||
| Store your object with the AddGadgetItem command and to get it back you have to cast it: Value:MyObject = MyObject( GadgetItemExtra:Object( gadget:TGadget , index ) ) |
| ||
As the docs say, EventExtra() returns the extra data
Global win:TGadget = CreateWindow("test", 10, 10, 250,200)
Global Quit:Int = False
Global listbox:TGadget = CreateListBox(4,4,100,80,win)
AddGadgetItem listbox,"One"
AddGadgetItem listbox,"Two",False,-1,ETIP
AddGadgetItem listbox,"Three",False,-1,"tip - goes here","mystringobject"
While Not Quit
WaitEvent()
Select CurrentEvent.ID
Case EVENT_GADGETSELECT
If EventSource()=listbox
Print String(EventExtra())
Case EVENT_WINDOWCLOSE
If CurrentEvent.Source = win Then Quit = True
EndSelect
Wend
End
|
| ||
| Thanks guys. Much appreciated. |