Page 1 of 1

escape key

Posted: Tue Sep 04, 2007 4:04 pm
by Greg Gammon
I need a code example of how to detect use of the escape key to close a window/dialog. I either need to be able to disable the escape key, or need to perform an action when escape is pressed (same action as exit key on my dialogs) which will release a logical lock.

Thanks in advance (again and again)
G

Posted: Tue Sep 04, 2007 5:40 pm
by James Bott
To prevent the user from exiting by using the Esc key:

ACTIVATE DIALOG oDlg;
VALID !GETKEYSTATE( VK_ESCAPE )


Or something like this:

By having a variable like :
local lClose := .F.

DEFINE DIALOG.....
DEFINE BUTTON..........ACTION (Any_Action(), lClose := .T., oDlg:End())

Some more code here.................

ACTIVATE DIALOG..... VALID lClose

If you do not do lClose := .T. you can never close the dialog the normal way. oDlg:End() when lClose == .F. does nothing.