#!/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(qw' -text $foo ')->pack; my $bar = $win->Entry(qw' -text $bar ')->pack; my $baz = $win->Entry(qw' -text $baz ')->pack; my $boo = $win->Entry(qw' -text $boo ')->pack; my $baa = $win->Entry(qw' -text $baa ')->pack; &defineOrder($foo,$baa,$bar,$boo,$baz); DumpBindtags($win, $foo,$baa,$bar,$boo,$baz); print " $win = \$win $foo = \$foo $bar = \$bar $baz = \$baz $boo = \$boo $baa = \$baa "; sub DumpBindtags { for my $o ( @_ ) { print "$o bindtags ( ", join ' , ' , $o->bindtags, " )\n"; } } sub defineOrder { my $widget; for (my $i=0; defined( $_[$i+1] ); $i++) { $_[$i]->bind('', [\&focus, $_[$i+1]]); # won't work with Tab $_[$i]->bind('all', '', [\&focus, $_[$i+1]]); #~ $_[$i]->bind( '', [\&focus, $_[$i+1]]); ## in order traversal } # Uncomment this line if you want to wrap around $_[$#_]->bind('', [\&focus, $_[0]]); $_[0]->focus; } sub focus { warn "focus @_\n"; my ($tk, $self) = @_; $self->focus; Tk::break(); } MainLoop(); __END__