Getting Enter key keypress on a TextField gadget

BlitzMax Forums/MaxGUI Module/Getting Enter key keypress on a TextField gadget

*(Posted 2007) [#1]
Is there any way of getting the enter key of a text field gadget?

I have tried a hotkey I have tried the Key events and nothing seems to work it always looses focus when I press enter an no event is created.


Dabz(Posted 2007) [#2]
If you mean somebody types in a textfield, then hits enter... create a button then hide it:-

Strict 

Local window:TGadget
Local textfield:TGadget
Local button:TGadget

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

textfield=CreateTextField(4,4,120,22,window)
SetGadgetText( textfield,"A textfield gadget" )

' we need an OK button to catch return key
button=CreateButton("OK",130,4,80,24,window,BUTTON_OK)
HideGadget button

While WaitEvent()
	Select EventID()
	Case EVENT_GADGETACTION
		Select EventSource()
			Case button
				Print "return key"
		End Select
	Case EVENT_WINDOWCLOSE
		End
	End Select
Wend


Minced up version from the docs.

Dabz


grable(Posted 2007) [#3]
Why not use SetGadgetFilter ?


Perturbatio(Posted 2007) [#4]
Why not use SetGadgetFilter ?

like this:

http://www.blitzbasic.com/Community/posts.php?topic=55626#619096