in reply to How do I suppress handlers when binding callbacks in Tk

Calling Tk->break from within your handler will prevent any further callbacks being called.

If the handler that you wish to supress is being called before your callback is processed, then you will need to either bind your callback at a higher level (say, to the class rather than the instance), or use $widget->bindtags to alter the order of the bindings.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: How do I suppress handlers when binding callbacks in Tk
by GrandFather (Saint) on Apr 23, 2006 at 22:48 UTC

    Thanks for that. The modification to my sample code to do what I wanted is:

    use strict; use warnings; use Tk; my $mw = MainWindow->new; my $text = $mw->Text ()->pack (-expand => 'yes', -fill => 'both'); $text->bindtags ([$text, ref($text), $text->toplevel, 'all']); $text->bind ('<Control i>', \&callback); MainLoop; sub callback { print "got a Control i\n"; Tk->break; }

    DWIM is Perl's answer to Gödel