Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I want to stay on a field?
Message
De
12/09/1997 17:20:15
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00049609
Message ID:
00049946
Vues:
47
>>>How do I send the FOCUS back to a field from a VALID?
>>Robert,
>>
>>You can only keep focus in a particular field with the VALID. If VALID returns .F., the error message is displayed and focus stays in that control. If the VALID returns 0, focus stays in the contorl but no error message is displayed.
>>
>>To SetFocus to a certain place on leaving a control, you can do that in the control's LostFocus event by simply;
>>
>> THISFORM.Control.SetFocus()
>
>Jim, as matter of understanding this logic (from a VFP newbie), I have to ask: how does any other control ever gain the focus if this control always grabs back the focus in its "LostFocus" event?
>I can only visualize that clicking on any other control would make this control "lose focus", and then the "lost focus" method would "SetFocus" immediately back to this control....
> This is the type of code I see that makes me wonder, how does a "never-ending loop" be avoided? Not that this is a wrong suggestion, just that I would like to understand the workings of VFP better...
>Thanks, Tom Hayward
setting focus back on the same (losing focus) control would only be in a got to finish this control state. A very simple one is a mandatory field and assume always allowed to enter so we don't need a WHEN
the setfocus() method could clear the text control (for example)
this.value=''
the valid() would check for
if empty(this.value) or isblank(this.value)
this.continue=.F. where continue is a custom text control property
and the lostfocus() would be
if not this.continue
this.setfocus()
endif
HTH
Gary
Helping Make Ideas Reality
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform