On Wed, Aug 02, 2006 at 01:32:49AM -0500, itsme213 wrote:
> In all of Squeaks inspectors, workspaces, etc. I want objects of class-A to
> display their name, and objects of class-B to display their number.
>
> What do I override to do this?
There are two methods in class Object that will help.
The #defaultLabelForInspector method determines the label that will
be used for an inspector window. You can see the default implementation
in class Object, and example of overriding the default in class Number.
You can implement #defaultLableForInspector in your class-A and class-B
to provide the labels that you want for inspectors.
The #printString method determines the human-readable representation
for an object. This is used for the window label in object explorers.
It is overridden in many classes, so just browse implementors to see
some examples. You can implement #printString in your class-A and class-B
to provide labels for object explorers.
If you want #defaultLabelForInspector and #printString to do the same
thing in each of your two classes, you can implement #printString first
(since this is the more general-purpose method), then have your
#defaultLabelForInspector methods refer to #printString (^ self printString).
That way, if you change the #printString methods, the #defaultLableForInspector
methods will always stay in sync.
Dave
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners