| 1 | package Tk::ChildNotification; | ||
| 2 | |||
| 3 | BEGIN | ||
| 4 | { | ||
| 5 | $Tk::ChildNotification::DerivedInitObject = \&Tk::Derived::InitObject; | ||
| 6 | $Tk::ChildNotification::WidgetInitObject = \&Tk::Widget::InitObject; | ||
| 7 | } | ||
| 8 | |||
| 9 | use vars qw ($VERSION); | ||
| 10 | use strict; | ||
| 11 | use Tk; | ||
| 12 | |||
| 13 | use Tk::Derived; | ||
| 14 | use Tk::Widget; | ||
| 15 | |||
| 16 | $VERSION = '0.01'; | ||
| 17 | |||
| 18 | sub Tk::Derived::InitObject | ||
| 19 | { | ||
| 20 | my $l_Return = &{$Tk::ChildNotification::DerivedInitObject} (@_); | ||
| 21 | $_[0]->parent()->ChildNotification (@_) if (defined ($_[0]->parent())); | ||
| 22 | return $l_Return; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub Tk::Widget::InitObject | ||
| 26 | { | ||
| 27 | my $l_Return = &{$Tk::ChildNotification::WidgetInitObject} (@_); | ||
| 28 | $_[0]->parent()->ChildNotification (@_) if (defined ($_[0]->parent())); | ||
| 29 | return $l_Return; | ||
| 30 | } | ||
| 31 | |||
| 32 | # | ||
| 33 | # Override this method when you want to know when a child has been | ||
| 34 | # created for you. Don't globally override it (leave out the 'Tk::Widget::' | ||
| 35 | # part). | ||
| 36 | # | ||
| 37 | sub Tk::Widget::ChildNotification | ||
| 38 | { | ||
| 39 | my ($this, $p_Child) = (shift, @_); | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; | ||
| 43 | |||
| 44 | __END__ |