Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bypass Validation when a Cancel button is pressed.
Message
De
10/11/1999 13:05:00
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00288499
Message ID:
00289699
Vues:
56
OIC now. How dumb I could be :) Keyboard buffer is clear but still lastkey() is 27. Poking another key then absorbing it is a way as you suggested. I also have another way :) Change first "if" line to read :
if !mdown() and lastkey() = 27
To also trap if control was losing focus with a mouse click. Interestingly this was the method I use to trap a row change in grid. Users love mice :)
Cetin

>Hi Cetin,
>
>I could reproduce it as well. Dump that code into 2 textboxes, put:
>thisform.textbox1.value = ''
>thisform.textbox2.value = ''
>into the cancel button and set .cancel = .t..
>
>Now Click in textbox1 then click in textbox2, the valid works as expected.
>Click in textbox1 type some text and then hit ESC, works as expected (no message). Now click back in textbox1, then click textbox2 (even though textbox1 is blank you don't get the messagebox). I think what is happening is the LASTKEY() is still returning 27 so the valid is failing.
>
>My workaround was to put a keyboard{space} in the cancel to reset lastkey().
>
>>>VALID EVENT
>>>* first check
>>>IF LASTKEY()=27
>>> RETU
>>>ENDIF
>>>*second check
>>>IF ISBLANK(THIS.VALUE)
>>> MESSAGEBOX('blank')
>>> RETU .F.
>>>ENDIF
>>
>>
Rajni,
>>To be able to help I should reproduce it but I can't. It works as intended. I suspect there is another code causing it. Also I noticed a sentence in your original post "When the Cancel button is pressed it clears the text from both of the text boxes without doing any validations. ". Why an Esc cause clearing of both textboxes. There should be some other code doing it unless both textboxes are bound to same controlsource such as a memvar.
>>Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform