in reply to Dealing with missing TK FocusOut event
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new Tk::MainWindow; my $btn = $mw->Button(-text => 'Hit Return', -command=> sub{ print 'Used Button' } )->pack(); my $btn_eg = $mw->Button(-text => 'Generate Return', -command=> sub{ $mw->eventGenerate('<Return>'); } )->pack(); # # Note that we *usually* bind to the main window, # not the button - it's a focus thing. # $mw->bind('<Return>', \&_on_rtn); MainLoop; exit(0); sub _on_rtn { $mw->messageBox( -message=>'Thanx for using the keyboard!'); }
|
|---|