Subject Re: USE of ENTER KEY
From Akshat Kapoor <akshat.kapoor@kapoorsons.in>
Date Thu, 23 Feb 2017 11:19:56 -0500
Newsgroups dbase.getting-started

Mervyn Bick Wrote:

> ON KEY LABEL has its uses and seems to be mostly used for setting the
> Function keys.  Depending on what Mustansir wants to do it may not be
> suitable here.
>
> Normally pressing Enter (or Tab) when a grid has focus moves the cursor
> to the next field.  Setting ON KEY LABEL ENTER CLASSNAME::WHATEVER() to
> execute code "swallows" the enter before it executes the code.  This
> means that although the code is executed the cursor doesn't move in the
> grid.  If this is what Mustansir needs then he can use ON KEY LABEL.
>
> If Mustansir wants pressing the Enter key to trigger code AND move the
> cursor there's a problem.  If he adds KEYBOARD "{enter}" to the code to
> replace the "swallowed" Enter he'll wind up with an infinite loop.
>
> In theory it should work if the ON KEY LABEL is disabled before
> keyboarding Enter and then resetting ON KEY LABEL afterward.  In
> practice this doesn't work as dBASE still enters an infinite loop. :-(
>
> Mervyn.

All very valid points.
If I trap a key using on key label then that key is not used for any other function.
Hence the necessity of declaring the on key label in ongotfocus event.
and removing the declaration in onlostfocus otherwise in case of enter key we will not be able to execute any command even from the command window. The only solution then is to quit dbase using the mouse.
Regards
Akshat