behavior with a listbox

BlitzMax Forums/MaxGUI Module/behavior with a listbox

Pax(Posted 2010) [#1]
Hi, I'm trying to get a listbox working, very simple from tutorial:

SuperStrict
Import MaxGui.Drivers

Local MyWindow:TGadget=CreateWindow("ListBox Example", 200,200,320,240)
Local ListBox:TGadget=CreateListBox(10,10,200,100,MyWindow)

For Local i:Int=10 To 15
  AddGadgetItem ListBox,i
Next 
Local s:String

Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_GADGETACTION
     s=GadgetItemText(ListBox,SelectedGadgetItem(ListBox))
     SetStatusText MyWindow, SelectedGadgetItem(ListBox) + ":" + s
   End Select
Forever


It runs, but I have have to click several times in order to get the selected gadget. After it's shown for the first time (status text), I still need to double click in order to refresh.

Is this the default behavior?
If it is, is there a way to just single click the item and refresh it sooner?

I'm using Blitzmax 1.37 and maxgui 1.39 on windows. Thanks in advance.


SebHoll(Posted 2010) [#2]
EVENT_GADGETACTION is emitted when an item is double-clicked - the event you are probably wanting to handle is EVENT_GADGETSELECT. Change the case qualifier in your example above, and it should work as you are perhaps expecting.


Pax(Posted 2010) [#3]
Thank you Seb, that was it.


SebHoll(Posted 2010) [#4]
Thank you Seb, that was it.

No problem! :-)

If you're unsure in future, checkout the corresponding CreateGadget() docs for a list of all the events that a gadget supports (e.g. in this case CreateListBox()).