Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
KeyPress ignores NODEFAULT
Message
From
21/06/2001 09:59:07
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00521694
Message ID:
00521883
Views:
18
Vlad,
This is not bad. Since my textbox class is based on inGrid, it will only be used in grids.
Thanks for your help.

>Hi!
>
>I found more generic workaround. Look to the events fired when you hit th ESC key. Th next event after all KeyPress events is a Valid of Grid. Return 0 from it cause form not close. I did following:
>
>* Grid init code
>this.addproperty('lNotValid')
>
>
>* KeyPressEvent code
>if nKeyCode = 27
> this.parent.parent.lNotValid = .T.
>endif
>
>* Grid Valid event
>if this.lNotValid
> this.lNotValid = .F.
> return 0
>endif
>
>
>Above way I managed to make form not close by ESC key. And it is much better encapsulation - you can add that code to your grid class that is parent for all other grids.
>
>HTH.
>
>>Vlad,
>>
>>SET ESCAPE doesn't make any difference. The problem seems to be related to the fact that the textbox is in a grid. Only the ESC key seems to be a problem since this textbox is a modified version of the InGrid class that uses lots NODEFAULTs that work without problems in the KeyPress.
>>
>>I used your idea of using the form's KeyPress event and check for the ESC key. This works, however I had to move the textbox.ilEditMode property to a form.ilEditMode. I don't like this since it's against encapsulation. But I currently don't see any other solution.
>>
>>Thanks for your help.
>>
>>>Hi!
>>>
>>>Just curious, did you set ESCAPE OFF? If it is ON, I guess it is the problem. If OFF... I guess it is because form handled key pressings separately if control did not handle them in grid. NODEFAULT should prevent this behavior, however, I'm not wondered because there are a lot of otehr problems in controls inside grid - bet you found one more ;)
>>>
>>>Try to put KeyPress code in the form KeyPress event and set form's property KeyPreview to .T.
>>>Another solution - try to use ON KEY LABEL definition or ON ESCAPE.
>>>
>>>HTH.
>>>
>>>
>>>>Hi,
>>>>I found a strange problem with a textbox class that I'm using in a grid. Here's some code from the KeyPress event:
>>>>
>>>>*-- textbox.KeyPress
>>>>LPARAMETERS nKeyCode, nShiftAltCtrl
>>>>
>>>>
>>>>DO CASE
>>>>	 CASE nKeyCode = -1  && F2 = Edit mode
>>>>	 	This.ilEditMode = .t.
>>>>	 CASE nKeyCode=27    && ESC
>>>>	 	IF This.ilEditMode
>>>>	 		*-- if we're in edit mode, reset mode and
>>>>	 		*-- suppress the ESC key
>>>>	 		*-- Note: this code doesn't work if the textbox is in grid!
>>>>			ThisForm.ilEditMode = .f.
>>>>			NODEFAULT
>>>>		ENDIF
>>>>	*-- etc...
>>>>ENDCASE
>>>>
>>>>The idea is to suppress the ESCAPE key if we're in edit mode. NODEFAULT doesn't prevent the form from being closed. The same textbox works perfectly if it's outside of the grid. Is this a known bug or am I missing something?
>>>>
>>>>Any ideas are appreciated.
Daniel
Previous
Reply
Map
View

Click here to load this message in the networking platform