Editable combobox events

BlitzMax Forums/BlitzMax Programming/Editable combobox events

JoshK(Posted 2006) [#1]
I would like an editable combobox to return the event data each time the contents are edited. I would also like it to return an event when the return key is hit. I am using an editable combobox to type script instructions into. Pressing return executes the command, and adds it into the combobox list, so that the command can be selected and executed again.


Beaker(Posted 2006) [#2]
Horrid workaround:
Strict 

Local window:TGadget
Local combobox:TGadget
Local retbutt:TGadget

window=CreateWindow("My Window",30,20,200,200)

combobox=CreateComboBox(4,4,120,22,window,COMBOBOX_EDITABLE)
AddGadgetItem combobox,"Short"
AddGadgetItem combobox,"Medium"
AddGadgetItem combobox,"Fat",True
AddGadgetItem combobox,"Humungous"

retbutt = CreateButton("Enter",125,4,40,20,window,BUTTON_OK)

While WaitEvent()
	Select EventID()
		Case EVENT_GADGETACTION
			Print "eventdata="+EventData()+" "+EventText()
			Select EventSource()
				Case retbutt
					Print ComboBoxText(combobox)
					AddGadgetItem combobox,ComboBoxText(combobox)

			End Select
		Case EVENT_WINDOWCLOSE
			End
	End Select
Wend



Function ComboBoxText:String(Gadget:TGadget)
	Local StrLen% = SendMessageA( QueryGadget(Gadget,QUERY_HWND),WM_GETTEXTLENGTH,0,0 )+1
	Local char_buff:Tbank = CreateBank(StrLen)

	SendMessageA( QueryGadget(Gadget,QUERY_HWND),WM_GETTEXT,StrLen,Int(BankBuf(Char_buff )));

	Local Res$
	For Local index% = 0 To StrLen-2
		Res$:+Chr(PeekByte(Char_buff,index))
	Next
	
	Return Res$
End Function