sub enable_tab {
my ($control, $nextcontrol) = @_;
# NB closure below - when the code runs, $control and $nextcontrol will have
# the values they do in this context here.
$control->bind("<Tab>" =>
sub {
$nextcontrol->focus();
$control->break();
} );
# make sure our new binding has priority
my @tags = $control->bindtags;
($tags[0], $tags[1]) = ($tags[1], $tags[0]);
$control->bindtags([@tags]);
}
I call it when I've created and packed my Texts:
enable_tab($textcontrol, $control_to_tab_to);