#!/usr/bin/perl use strict; use warnings 'all'; use Tk; use Tk::Text; { package Tk::MyText; use base qw(Tk::Text); Construct Tk::Widget 'MyText'; sub ClassInit { my($class,$mw) = @_; $class->SUPER::ClassInit($mw); $mw->bind($class, '', sub { Tk->break }); $class; } } use Hook::WrapSub qw(wrap_subs); wrap_subs sub { warn "called focus with args @_" }, 'Tk::focus', sub {}; my $mw = tkinit; my $text = $mw->Scrolled('MyText', -scrollbars => 'ose', -background => 'white', -wrap => 'none') ->pack(-fill => 'both', -expand => 1); $text -> focus(); MainLoop; __END__