Is there a smarter way of stopping ESC from being passed from one form
to another?

For example, I have a formA.txt.valid() that returns .t. if lastkey()=27
for shutting down the form.

I then called up a search form, and pressed ESC. The lastkey() will
become 27. Now formA would see it, and formA.txt will react incorrectly.

I am doing these in all search forms' unload() method:

keyboard chr(254)
inkey()


--
iTech Consulting Co., Ltd.
Specialized in providing ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852) 2325 3883 Fax: (852)2325 8288

Re: laskey()=27 by Man-wai

Man-wai
Fri Jan 05 05:33:39 CST 2007

Man-wai Chang wrote:
>
> Is there a smarter way of stopping ESC from being passed from one form
> to another?
>
> For example, I have a formA.txt.valid() that returns .t. if lastkey()=27
> for shutting down the form.
>
> I then called up a search form, and pressed ESC. The lastkey() will
> become 27. Now formA would see it, and formA.txt will react incorrectly.
>
> I am doing these in all search forms' unload() method:
>
> keyboard chr(254)
> inkey()
>
>

In short, make/localize lastkey() to depends on activeform.

--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10) Linux 2.6.19.1
^ ^ 19:32:01 up 24 days 1:44 0 users load average: 1.04 1.03 1.00
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

Re: laskey()=27 by christophe

christophe
Fri Jan 05 06:44:05 CST 2007

Hi,

why not trap the esc key in the forms keypress
with yourform.keypreview = .T.
and a NoDefault ?

something like this :
yourform.keypress
lparameters nkeycode,nshiftaltctrl
if nkeycode = 27
nodefault
thisform.release &&or whatever you want
endif

regards
christophe

"Man-wai Chang" <toylet.toylet@gmail.com> schreef in bericht
news:ORldS1LMHHA.3556@TK2MSFTNGP03.phx.gbl...
> Man-wai Chang wrote:
>>
>> Is there a smarter way of stopping ESC from being passed from one form
>> to another?
>>
>> For example, I have a formA.txt.valid() that returns .t. if lastkey()=27
>> for shutting down the form.
>>
>> I then called up a search form, and pressed ESC. The lastkey() will
>> become 27. Now formA would see it, and formA.txt will react incorrectly.
>>
>> I am doing these in all search forms' unload() method:
>>
>> keyboard chr(254)
>> inkey()
>>
>>
>
> In short, make/localize lastkey() to depends on activeform.
>
> --
> .~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
> / v \ Simplicity is Beauty! May the Force and Farce be with you!
> /( _ )\ (Ubuntu 6.10) Linux 2.6.19.1
> ^ ^ 19:32:01 up 24 days 1:44 0 users load average: 1.04 1.03 1.00
> news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk



Re: laskey()=27 by Olaf

Olaf
Fri Jan 05 06:55:16 CST 2007

>> keyboard chr(254)
>> inkey()

this works for me.

Maybe try
keyboard chr(254) plain clear
inkey()

And maybe try
if lastkey()=27 and chrsaw()
in the valid event, but I'd say
the key then is already consumed,
so chrsaw() would return .F. both
in the formB and the formA.

An event for each form (with the scope
as the form) is the keypress event.
Set the forms keypreview property to .T.
and every keystroke made during a form
being active will then be passed in there
first, so you could also set a forms property
(eg lCancel) to .T. if you get an ESC
(nKeycode 27) there and react to this instead
of lastkey()=27.

Bye, Olaf.

Re: laskey()=27 by Man-wai

Man-wai
Fri Jan 05 08:36:48 CST 2007

> why not trap the esc key in the forms keypress
> with yourform.keypreview = .T.
> and a NoDefault ?

No, I am not trying to trap the key, but to prevent lastkey() of
called_form from reaching to calling_form.

--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10) Linux 2.6.19.1
^ ^ 22:35:01 up 24 days 4:47 0 users load average: 1.00 1.02 1.00
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

Re: laskey()=27 by Olaf

Olaf
Fri Jan 05 08:55:40 CST 2007


"Man-wai Chang" <toylet.toylet@gmail.com> schrieb im Newsbeitrag news:eOhOjbNMHHA.448@TK2MSFTNGP04.phx.gbl...
>> why not trap the esc key in the forms keypress
>> with yourform.keypreview = .T.
>> and a NoDefault ?
>
> No, I am not trying to trap the key, but to prevent lastkey() of
> called_form from reaching to calling_form.
well, you don't need to call nodefault,
still keypress()-event gives you the keypresses
done for the active form.

Bye, Olaf.