#!/usr/bin/perl use strict; use warnings 'all'; use Tk; use Tk::Text; use Hook::WrapSub qw(wrap_subs); wrap_subs sub { warn "called focus with args @_" }, 'Tk::focus', sub {}; my $mw = tkinit; my $text = $mw->Scrolled('Text' => -scrollbars => 'ose', -background => 'white', -wrap => 'none') ->pack(-fill => 'both', -expand => 1); $text -> focus(); $text -> bind('', sub { $text->focus(); $text->break; }); MainLoop; _ _ END _ _ called focus with args Tk::Text=HASH(0x82dbcb4) at /tmp/b.pl line 8. called focus with args Tk::Scrollbar=HASH(0x839f6f4) at /tmp/b.pl line 8. called focus with args Tk::Text=HASH(0x82dbcb4) at /tmp/b.pl line 8.