Reacts to double-click only.. Want single-click.

BlitzMax Forums/BlitzMax Beginners Area/Reacts to double-click only.. Want single-click.

Well, there have been a lot of problems in the past with gadgets generating events when they are changed programatically.

I made a function that allows you to work around these sorts of problems that kills events of a particular type. Don't really know how effecient it is (probably could be better), but it does the job.

Try this for now:
Local MyWindow:TGadget=CreateWindow("no title", 200,200,420,240)
Local List:TGadget=CreateListBox(10,10,75,100,MyWindow)

Local TextBox:TGadget=CreateTextArea(100,10,300,100,MyWindow)	

For Local i=1 To 50
  AddGadgetItem List,i
Next

Rem
AddTextAreaText (TextBox,"This text causes an EVENT_GADGETSELECT")
End Rem

Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_GADGETSELECT
     Notify "You (may) have clicked!"
     AddTextAreaText (TextBox,"This sucks!"+Chr$(13))
	KillEvent(EVENT_GADGETSELECT)
   End Select
Until EventID()=EVENT_WINDOWCLOSE


Function KillEvent(pID%,pID2%=0)
		
		Local tmpList:TList = New TList
		
		PollSystem()
		
		tmpList.AddFirst CurrentEvent;PollEvent
		
		While EventID() <> Null
		
			If Not (EventID() = pID Or EventID() = pID2) Then tmpList.AddLast CurrentEvent		
		
			PollEvent()
		
		Wend
		
		For Local a:TEvent = EachIn tmpList
		
			PostEvent(a)
		
		Next
		
		PollEvent()

EndFunction
If anyone else considers this event generation as a bug, you may want to create a new topic regarding this in the MaxGUI Bug Reports topic.