diff options
-rw-r--r-- | Perl/Zinc/Debug.pm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Perl/Zinc/Debug.pm b/Perl/Zinc/Debug.pm index bc3dcfc..e346f48 100644 --- a/Perl/Zinc/Debug.pm +++ b/Perl/Zinc/Debug.pm @@ -52,12 +52,14 @@ my %instances; my @instances; my %cmdoptions; my $initobjectfunction; + sub BEGIN { # test if ZincDebug is loaded using the -M perl option $preload = 1 if (caller(2))[2] == 0; return unless $preload; # parse ZincDebug options require Getopt::Long; + #Getopt::Long::Configure('pass_through'); Getopt::Long::GetOptions(\%cmdoptions, 'itemModBtn=s', 'tkey=s', 'optionsToDisplay=s', 'optionsFormat=s', 'color=s', 'enclosedModBtn=s', 'overlapModBtn=s', 'searchKey=s', @@ -65,17 +67,18 @@ sub BEGIN { ); # save current Tk::Zinc::InitObject function; it will be invoked in # overloaded one (see below) - $initobjectfunction = \&Tk::Zinc::InitObject; + $initobjectfunction = Tk::Zinc->can('InitObject'); + *Tk::Zinc::InitObject = *InitObject; } # Hack to capture the instance of zinc. ZincDebug functions are invoked here. # Note that created bindings might be overloaded by the application. -sub Tk::Zinc::InitObject { +sub InitObject { Tk::Widget::InitObject(@_); + #print "Tk::Zinc::InitObject\n"; # invoke function possibly overloaded in other modules - &$initobjectfunction; - #print "***** ZincDebug Tk::Zinc::InitObject zinc=$_[0]\n"; + &$initobjectfunction(@_) if $initobjectfunction; return unless $preload; my $zinc = $_[0]; my @options = (); |