in reply to Tab Order for Widgets in HList
Not to hijack the thread, but I ran into some Tab troubles when trying to work on this problem. The code below is supposed to be a general purpose routine for defining focus order, but if you try it, it works for the Enter key, but not Tab! Can anyone enlighten me as to why Tab is hard coded to pass focus the way it does?
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
#!/usr/bin/perl use Tk; use strict; use warnings; #changes focus on Return(Enter) key but not Tab my $win = MainWindow->new(); my $foo = $win->Entry->pack; my $bar = $win->Entry->pack; my $baz = $win->Entry->pack; my $boo = $win->Entry->pack; my $baa = $win->Entry->pack; &defineOrder($foo,$baa,$bar,$boo,$baz); sub defineOrder { my $widget; for (my $i=0; defined( $_[$i+1] ); $i++) { $_[$i]->bind('<Key-Return>', [\&focus, $_[$i+1]]); # won't work with Tab $_[$i]->bind('all', '<Tab>', [\&focus, $_[$i+1]]); } # Uncomment this line if you want to wrap around $_[$#_]->bind('<Key-Return>', [\&focus, $_[0]]); $_[0]->focus; } sub focus { my ($tk, $self) = @_; $self->focus; } MainLoop();
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Tab Order for Widgets in HList
by Anonymous Monk on Oct 19, 2011 at 14:59 UTC |
In Section
Seekers of Perl Wisdom