Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re:^4 changing the focusing-order in Tk

by hiseldl (Priest)
on Sep 28, 2002 at 22:34 UTC ( [id://201499]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: changing the focusing-order in Tk
in thread changing the focusing-order in Tk

Try this:

use Tk; use strict; use warnings; my $win = MainWindow->new(); $win->Button(-text=>'Other Window',-command=>\&otherwindow)->pack; sub otherwindow { my $otherwin = $win->Toplevel; my $foo = $otherwin->Entry->pack; my $bar = $otherwin->Entry->pack; my $baz = $otherwin->Entry->pack; &defineOrder($foo, $bar, $baz); } sub defineOrder { my $widget; for (my $i=0; defined( $_[$i+1] ); $i++) { $_[$i]->bind('<Key-Return>', [\&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();

This changes focus to the next widget using the return key. The focus does not wrap around, but you should be able to add an extra bind command to go from the last widget to the first widget using the example above.

--
hiseldl
What time is it? It's Camel Time!

Replies are listed 'Best First'.
Re: Re:^4 changing the focusing-order in Tk
by schweini (Friar) on Sep 29, 2002 at 02:14 UTC
    okay, this one works - thanks a million!

    but what the heck are you doing there? giving of a list as a coderef, and perl thinks the first element is a sub? yikes!
    thanks again,
    -schweini

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://201499]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-28 23:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found