Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More than one tab cycle
Message
De
04/08/2006 17:51:47
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
À
04/08/2006 15:51:25
Hans-Otto Lochmann
Dr. Lochmann Consulting Gmbh
Frankfurt, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01142829
Message ID:
01143109
Vues:
10
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Greg,
>Hi Dragan,
>
>many thanks for your proposals.
>
>For the moment being I solved the problem on hand by hard-coding everything. Not very elegant, but it is working.
>
>On the other hand I think I explained poorly what I have in mind. Tamar Granor's FPW 2.6 solution used two invisible command buttons at each end of the group. In its When events each of these invisible command buttons called a sub. In this sub the "next" object to receive focus was determined by using _Curobj and Objnum(). If you put one of these invisible command buttons at the beginning of the tab order and the other one at the end of it, then you could have this "merry go round" in both directions (forward and backward) by using some keys, among others the tab key, the up and down arrows, the enter key and do forth.
>
>I want to some generic solution, which will work in VFP 9 and up. Unfortunately the When event does not allow to call the SetFocus method of another object. Also I did not find a way to address an object by its TabIndex. This would allow me to call the next or previous object in the tab sequence.
>
>Example: Let us assume that I could address an object via its TabIndex. Let further assume, that I have seven TextBoxes, having the TabIndices 2 to 8 and two invisible objects, say CommandButton cmdFrontEnd and cmdBackEnd, having the TabIndex 1 and 9 respectively. When moving forward using the enter key or tab key or down arrow or … then cmdFrontEnd would pass the focus to the TextBox with TabIndex 2, which then would pass the focus to the TextBox with TabIndex 3 and so on. TextBox with TabIndex 8 would then pass the focus to the invisible CommandButton cmdBackEnd, which then would pass the focus to the cmdFrontEnd, which then would pass the focus to the TextBox with TabIndex 2 and so forth. The same mechanism would work in the other direction as well. As the When event in both invisible command buttons always returns .f. the user would not notice their working. Leaving a group could easily be facilitated by using page up or down or by as-signing hot keys to suitable objects.
>
>Well, if I could address an object using its TabIndex… then this could lead to a generic solution, which is, what I am looking for.

You actually can, and it's not that hard. You need an array property in the .parent object, be it a form, page or container. Do this somewhere in its .init:
this.addproperty("aTabObj[1,1]")
dimension this.aTabObj[this.objects.count, 2]
for i=1 to this.objects.count
   this.aTabObj[i,1]=this.objects[i].taborder
   this.aTabObj[i,1]=this.objects[i]
endfor
asort(this.aTabObj,1)
You may need to skip objects without taborder (like labels and shapes).

Then any object which needs to know its next or previous object in the tab order only needs to find its index in the array, and access the next (or first, if he's the last) object there, and setfocus() to it.
*-- last control's lostfocus()
nMe=ascan(this.parent.aTabObj, this.taborder)
if nMe=alen(this.parent.aTabObj,1) or nMe=0
  nMe=1
endif
loNextCtl=this.parent.aTabObj[nMe, 2]
loNextCtl.SetFocus()
nodefault
IIRC, the nodefault should prevent the next object in tab order from gaining focus on exit from this method.

This should work if you're grouping them in containers; if you want to have multiple groups within a form without putting them into containers, you may assign specal properties to end controls (first, last) and check for those properties. Then the above .lostfocus could actually be bindevent()ed somewhere else and doesn't have to be in the control itself.

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