Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find out the control focus is jumping to?
Message
De
19/12/2008 09:57:59
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
18/12/2008 18:52:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01368256
Message ID:
01368828
Vues:
11
>>>If I were to do it as you have suggested, that means I will have to add code to GetFocus event of almost all controls in the form and I think I can easily forget about adding the same code, if in the future I need to add new control to the form.
>>
>>In the init of the form, you can build an array property, which would hold a reference to all of the controls which can get focus, and their tab order, sorted by 2nd column. The reference may be just names, and not even recursive if you don't need it to - containers are a single focus unit anyway. Then you can have a method called NextInTabOrder(toAfterThisControl), which would find your current control's row in the array, and return a reference to the next control.
>>
>>Note: if you build references in the array via sys(1272), the form's name isn't what you'd expect until form's .init() exits - it's the classname or something equally generic; only after the init, when the object formally exists, it gets its .name property set. When referencing objects via their sys(1272) string, replace the first segment with "thisform".
>>
>>Note2: if you keep references as object references, take care to null them all in the cleanup. Automatic cleanup may work, but once it doesn't, you'll be too busy with something else.
>
>But I was initially looking for a way to determine where focus is heading (inside LostFocus event), I mean it could be cause by a mouse click that jump the focus to any control from the current one, which means it has nothing to do with tab order.

You'd need to bind every control's when() then, so they would report to the form.activecontrol (which should still be active, at least until .when() exits) that they are about to get focus, and then the activecontrol would know what to do - lots of code there, if you want to cover all cases. Also, .when() is one of those events which need some code or else binding doesn't work. Another tricky part is to make sure this "original" code doesn't run, i.e. if you don't want to pass focus... well, maybe it doesn't matter whether this bound .when() returns .t. or .f., if you .setfocus() to the previous control.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform