Some code to show what happens:
#!/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_old { 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 defineOrder { my $widget; for (my $i=0; defined( $_[$i+1] ); $i++) { $_[$i]->bind( '<Key-Return>', [\&focus, $_[$i+1]]); $_[$i]->bind( '<Tab>', [\&focus, $_[$i+1]]); } # Uncomment this line if you want to wrap around $_[ $#_ ]->bind('<Key-Return>', [\&focus, $_[0]]); $_[ $#_ ]->bind('<Tab>', [\&focus, $_[0]]); $_[0]->focus; } sub focus { my ($tk, $self) = @_; $self->focus; } MainLoop();
In reply to Re: Entry widget does not work in 5.18.1
by zentara
in thread Entry widget does not work in 5.18.1
by rjohn1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |