MaxGUI problem with ListBoxes

BlitzMax Forums/BlitzMax Beginners Area/MaxGUI problem with ListBoxes

Ashes(Posted 2014) [#1]
I am running through the great tutorials for MaxGUI that Assari made. I reached tutorial 8 and I encountered some strange behavior.

Here is the code:
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=1000 To 1050
	AddGadgetItem Listbox,i
Next


Repeat	
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_GADGETACTION
			SetStatusText MyWindow,"Item Selected="+SelectedGadgetItem(ListBox)
	EndSelect
	
Forever


It is supposed to set the window status to gadget item number, however that only happens if I double click an item instead of single clicking it. Do you have any idea why it happens and how to fix it?


TomToad(Posted 2014) [#2]
The behavior was changed since the tutorials were written. EVENT_GADGETACTION was originally emitted when you clicked on an item. Now it will only fire on a double click. To detect a single click on an item, use EVENT_GADGETSELECT instead.


skidracer(Posted 2014) [#3]
The behavior you are expecting is Event ID EVENT_GADGETSELECT which is documented in the CreateListBox help.


Ashes(Posted 2014) [#4]
That's perfect. Thank you guys.