June 26, 2024, 01:09:53 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Detect Enter Key when press

Started by Andy, October 02, 2009, 03:56:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi Everyone,

This propbably a simple question to answer, but I cannot find how to do this and have spent some time with this problem:

1. I use openwindow command
2. have a text box for the user to enter a password
3. A second text box to confirm the password

How do I detect the user has pressed the 'Enter' key ?

Sorry if this is such a basic question - can anyone help with a little example ?

Thank You all so much,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

ZeroDog

If the edit control is a single line control, the system will detect when the enter key has been pressed, and will press the current window/dialog default button.  You can specify the window/dialog default button by using the @CTLBTNDEFAULT flag with the control creation function for the button.

mrainey

From the User Guide:

@ENTABKEY

The user has pressed the TAB key while the control has input focus. Only sent if enabled by the SETCONTROLNOTIFY command.

@ENENTERKEY

The user has pressed the ENTER key while the control has input focus. Only sent if enabled by the SETCONTROLNOTIFY command.



Example from the EB sample files:


WINDOW win
OPENWINDOW win,0,0,295,199,0,0,"Caption",&handler
CONTROL win,@EDIT,"Press Enter or TAB",83,39,124,27,0x50800000|@CTEDITAUTOH,5
SETFONT win,"Ariel",9,400,0,5
SETCONTROLNOTIFY(win,5,1,1)
SetFocus win,5
WAITUNTIL win=0
END

SUB handler
SELECT @MESSAGE
CASE @IDCONTROL
IF @CONTROLID = 5
SELECT @NOTIFYCODE
CASE @ENENTERKEY
MESSAGEBOX win,GetControlText(win,5),"Enter Pressed!"
SetFocus win,5
CASE @ENTABKEY
MESSAGEBOX win,"Tab key pressed","Info"
SetFocus win,5
ENDSELECT
ENDIF
CASE @IDCREATE
CENTERWINDOW win
CASE @IDCLOSEWINDOW
CLOSEWINDOW win
ENDSELECT
RETURN
ENDSUB
Software For Metalworking
http://closetolerancesoftware.com

Andy

Thanks everyone!

I will give it go and once again thanks!

Andy
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.