#!/usr/bin/perl use Tk; use strict; package MyButton; # see perldoc Tk::mega use base qw/Tk::Derived Tk::Button/; Construct Tk::Widget 'MyButton'; sub ClassInit { my ($class, $mw) = @_; $class->SUPER::ClassInit($mw); # $mw->bind($class, '', sub{print "Entered a MyButton\n"}); } sub Populate { my ($self, $args) = @_; $self->SUPER::Populate($args); $self->bind('', sub{print "Entered a MyButton\n"}); # my (@bt) = $self->bindtags; # $self->bindtags( [ @bt[ 1, 0, 2, 3 ] ] ); } 1; package main; my $mw = MainWindow->new; $mw->Button(-text => 'NormalButton')->pack; $mw->MyButton(-text => 'MyButton')->pack; MainLoop;