You can use the "raise" and "lower" command to control the stacking
order.  I made a simple 
program with VTCL that has 4 entry boxes that appear to be stacked
vertically using the place geometry manager.  Here's the section of code
that builds them
from VTCL:

    entry $base.ent35 \
        -cursor {} 
    entry $base.ent36 \
        -cursor {} 
    entry $base.ent37 \
        -cursor {} 
    entry $base.ent38 \
        -cursor {} 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.ent35 \
        -x 40 -y 20 -anchor nw -bordermode ignore 
    place $base.ent36 \
        -x 40 -y 75 -anchor nw -bordermode ignore 
    place $base.ent37 \
        -x 40 -y 105 -anchor nw -bordermode ignore 
    place $base.ent38 \
        -x 40 -y 45 -anchor nw -bordermode ignore 

    raise $base.ent38 $base.ent35

}

If you notice, they are all at -x 40 but .ent38 is at -y
45 so it gets placed second in the vertical stack just below .ent35 in
the GUI even  though it was created last. This
causes the tab traversal in the GUI when starting from the
top most entry showing in the GUI to go from the top to the 3rd then the
4th then back
to the second (in the vertical stack in the GUI). If you want
to override the stacking order so the cursor will tab from 
top to bottom in the order they display in GUI, rather than the order
they were created,  all you have
to do is add the line at the bottom "raise $base.ent38 $base.ent35" This
caused the stacking order to change and $base.ent38 will be moved to
second in the stacking order, just after $base.ent35 even though
it was originally last in the stacking order when the widgets
were created (which set the original stacking order). I found
that if I put the raise command in this place, it still loads
in VTCL, but when you save from VTCL, it will be removed, so 
you will need to put it in in a proc that VTCL will not remove
and then call the proc to cause the stacking order to change.

There is also a "lower" command that does the opposite maneuver.  If you
don't give a second parameter to the raise
or lower command, it will move the widget to the top or bottom
of the stacking order respectively.



Alex Caldwell




Rick Macdonald wrote:
> 
> On Mon, 11 Dec 2000, Mark Swarbrick wrote:
> 
> > Yes, I am using the place command. I'm building this with Visual Tcl and the
> > place command is what it is using, so I guess what you say doesn't apply...?
> > So I'm back where I started  - I've got a nice gui all built but tabbing to the
> > entry boxes is really messed up.  Surely there is an easy way to change this.
> > Sure hope someone can help me.
> >
> > ...Mark
> >
> > On Sat, 02 Dec 2000, Rick Macdonald wrote:
> 
> > > Ah, if you are using the "place" geometry manager in vTcl, probably none
> > > of the vTcl instructions above apply...
> 
> Well, I've never used the place command, so I don't know how to fix it
> within vTcl. Hopefully someone who does is listening!
> 
> If you're really desperate, here is a function from TkGnats that, given a
> list of widgets, sets the tab traversal order to the order of the list:
> 
> proc set_text_traversal {tlist} {
>     set ll [llength $tlist]
>     if {$ll < 2} {
>         return
>     }
>     for {set x 1} {$x<$ll} {incr x} {
>         set w [lindex $tlist $x]
>         set prevw [lindex $tlist [expr $x-1]]
>         bind $prevw <Tab>       "focus $w
>         break"
>         bind $prevw <Control-n> "focus $w"
>     }
>     bind [lindex $tlist [expr $ll-1]] <Tab>       "focus [lindex $tlist 0]
>     break"
>     bind [lindex $tlist [expr $ll-1]] <Control-n> "focus [lindex $tlist
> 0]"
> 
>     bind [lindex $tlist 0] <Shift-Tab> "focus [lindex $tlist [expr $ll-1]]
>         break"
>     bind [lindex $tlist 0] <Control-p> "focus [lindex $tlist [expr
> $ll-1]]"
>     for {set x 0} {$x < [expr $ll-1]} {incr x} {
>         set w [lindex $tlist $x]
>         set nextw [lindex $tlist [expr $x+1]]
>         bind $nextw <Shift-Tab> "focus $w
>         break"
>         bind $nextw <Control-p> "focus $w"
>     }
> }
> 
> ...RickM...
> 
> _______________________________________________
> vtcl-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/mailman/listinfo/vtcl-user
_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/vtcl-user

Reply via email to