Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Perl/Tk binding Tab

by zentara (Archbishop)
on Oct 31, 2018 at 18:16 UTC ( #1225013=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl/Tk binding Tab
in thread Perl/Tk binding Tab

Hi, it may help to know that the calling widget is the first argument $_[0] pass to any Tk callback. This code may show you what is happening. Notice how the Entry widget changes with each Tab.
#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = MainWindow->new(); my $entry1 = $mw->Entry()->pack(); my $entry2 = $mw->Entry()->pack(); my $entry3 = $mw->Entry()->pack(); my %after = ($entry1 => $entry2, $entry2 => $entry1, ); $mw -> bind('all','<Tab>',sub{ print "@_\n"; ($after{$_[0]} // $_[0])->focus; } ); $mw->MainLoop(); exit(0);

I'm not really a human, but I play one on earth. ..... an animated JAPH

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2019-10-17 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?