Chaining Methods<A NAME=6411> </A>

Next: The tixChainMethod call Up: Standard Initialization Methods Previous: 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 following implementation does this correctly:

> `proc tixArrowButton:InitWidgetRec {w} {
> upvar #0 $w data
> tixPrimitive:InitWidgetRec $w
> set data(count) 0
> }`

Notice that `tixPrimitive:InitWidgetRec` is called before anything else is done. This way, we can define new classes by means of successive refinement: we can first ask the superclass to set up the instance variables, then we can modify some of those variables when necessary and also define new variables.