Ok, this is kind of tricky, but possible. In Tcl, you could do it like this:
So you might think that a straight translation of that would work for Perl/Tk, but it doesn't. (I tried it.)bind .t1 <Tab> { focus [tk_focusNext .t1]; break }
The reason that a straight translation doesn't work is because Perl/Tk changed the default order that bindtags uses. To change the binding, either subclass and change it, as suggested above, or simply reorder the bindtags for the widget and then you can do the rebind:
If you're observant, you'll also notice one other place where it wasn't a straight translation. In Tcl, tk_focusNext just returns the name of the next widget in focus order, then you have to actually call focus on it. In Perl/Tk, it just sets the focus directly.# fix the bindtags order so that widget events are # processed before class events $t1->bindtags( [ ($t1->bindtags)[1,0,2,3] ] ); # now give the text widget a new Tab binding $t1->bind( '<Tab>', sub { $t1->focusNext; Tk->break; } );
In reply to Re: re-binding Tab in a TK Text field
by kelan
in thread re-binding Tab in a TK Text field
by wolfger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |