in reply to Tk preventing a char in Entry widged to trigger a KeyBinding
#!/usr/bin/perl # http://perlmonks.org/?node_id=1173709 use strict; use warnings; use Tk; # use Tk::WidgetDump; # use Tk::ObjScanner; my $mw = MainWindow->new(); $mw->geometry("100x100+799+336"); $mw->bind('<KeyRelease-question>' => sub{print "A question mark was pr +essed!!\n"} ); my $entry = $mw->Entry( -text => '',-width => 20)->pack(); $entry->bind('<Enter>' => sub { $mw->bind('<KeyRelease-question>' => s +ub {})}); $entry->bind('<Leave>' => sub { $mw->bind('<KeyRelease-question>' => sub{print "A question mark was pressed!!\n"})}); # $mw->WidgetDump(); MainLoop;
You could also try with FocusIn and FocusOut, or some combination of the two types.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk preventing a char in Entry widged to trigger a KeyBinding
by choroba (Cardinal) on Oct 11, 2016 at 22:01 UTC | |
by Discipulus (Canon) on Oct 12, 2016 at 07:38 UTC | |
by Anonymous Monk on Oct 12, 2016 at 08:02 UTC | |
by Discipulus (Canon) on Oct 12, 2016 at 08:46 UTC | |
by tybalt89 (Monsignor) on Oct 11, 2016 at 22:25 UTC | |
|
Re^2: Tk preventing a char in Entry widged to trigger a KeyBinding
by Anonymous Monk on Oct 11, 2016 at 20:16 UTC |