Basic query:How to detect "enter/return" press
BlitzPlus Forums/BlitzPlus Beginners Area/Basic query:How to detect "enter/return" press
| ||
| Really basic query - can't believe I'm asking this, but can't work out how to do it with blitzplus gui: How do I detect an "ENTER" or "RETURN" key pressed while in a text field. I've tried using event $401, $103 even a HotKeyEvent but cannot seem to detect the pressing of the enter key:
window = CreateWindow("Simple Entry Screen",GadgetWidth(Desktop())/4,GadgetHeight(Desktop())/4,400,400)
fntArial36 = LoadFont("Arial",36)
lbl1 = CreateLabel("ID Number",90,75,200,40,window)
SetGadgetFont lbl1,fntArial36
txtinput = CreateTextField (90,120,200,40,window)
SetGadgetFont txtinput,fntArial36
timer=CreateTimer(0.33)
ActivateGadget txtinput
HotKeyEvent 28,0,$4001
Repeat
WaitEvent()
Select EventID()
;case $103 ; case $401 ; what do I use to detect an ENTER or RETURN while in txtinput??
Case $4001
;collect user id if text field non blank
Case $803
If Confirm ("Quit:Are You Sure?") Then End
End Select
Forever
Thanks for any assistance. |
| ||
| http://www.blitzbasic.com/Community/posts.php?topic=56161#1007496 |
| ||
Thanks for the assistance, I've posted the relevant code here (that you posted in the other thread) as well in case anyone is after the same thing. I must say though - it is a bizarre fix.
W = CreateWindow("Blub",100,100,200,200,Desktop(),1)
T = CreateTextField(10,40,70,20,W)
B = CreateButton("OK",100,40,40,20,W,4) ; You can hide this or set 0 for width and height if you don't want it to be seen.
Repeat
Select WaitEvent()
Case $803 End
Case $401
If EventSource() = B Then Notify "you pressed Return in the textfield!"+Chr(13)+"Or you clicked the Button..."+Chr(13)+"Your Text: "+TextFieldText(T)
End Select
Forever
|
| ||
| erm just in case you didn't know event $4001 is a timer tick event you'd better use a custom thin like $3012 or whatever |
| ||
| Hi Stamm, I realise event $4001 is a timer tick event - I use it to check and clear the contents of the text field every 'n' seconds - useful for what we do at work |
| ||
| oh ok i didint know that |