subsubsection3_4_5_1.html
section3_4.html
subsubsection3_4_4_1.html
tableofcontents3_1.html
Next:
subsubsection3_4_5_1.html
The ConstructWidget Method
Up:
section3_4.html
Tix Object Oriented
Previous:
subsubsection3_4_4_1.html
The InitWidgetRec Method
Chaining Methods
The above implementation is not sufficient because our
TixArrowButton
class is derived from
TixPrimitive
. The class derivation in Tix is
basically an is-a relationship:
TixArrowButton
is a
TixPrimitive
.
TixPrimitive
defines the method
tixPrimitive:InitWidgetRec
which sets up the instance variables of
every instance of
TixPrimitive
. Since an instance of
TixArrowButton
is
also an instance of
TixPrimitive
, we need to make sure that the
instance variables defined by
TixPrimitive
are also properly
initialized. The technique of calling a method defined in a superclass
is called the chaining of a method.
The
tixChainMethod
command will automatically
find a superclass that defines the method we want to chain and calls
this method for us. For example:
proc tixArrowButton:InitWidgetRec {w} {
upvar #0 $w data
tixChainMethod $w InitWidgetRec
set data(count) 0
}
Notice the order of the arguments for
tixChainMethod
: the name of the
instance,
$w
, is passed before the method we want to chain,
InitWidgetRec
.
subsubsection3_4_5_1.html#SECTION00045100000000000000
The ConstructWidget Method
subsubsection3_4_5_2.html#SECTION00045200000000000000
The SetBindings Method
http://tix.sourceforge.net
http://tix.sourceforge.net
