Morphic - widget subclassing and inheritance

Geza Lakner MD geza67 at freestart.hu
Wed Aug 6 13:22:58 UTC 2003


Dear The Squeakers!

I am a newbie in Morphic and Smalltalk, and I just can't get around
with this one. First, it is very painful to build and handle a usable,
conventional dialog box in Morphic.
This was my way, please comment it if there is a more "squeakish" (...
elegant..) way to do it:

1. make a morphic project
2. add a system window morph via the World menu
3. add a button via the World menu
4. add a text field via the World menu
5. embed 3-4. into 2 via the halo menu

Now, all these GUI mparts are programatically, practically inaccesible
in the usual way. They have no global names (just some instantiation
number in parenthesis), nor could they be pruned into existing classes
via renaming or something like this. The only way I saw, is to
subclass each widget. So I subclassed the button, and redefined
doButtonAction. For testing purpose it was a tiny 'Transcript show:'
message. It worked. I exhaled.

Now for the hard part. Although I subclassed the text field, no
messages from its superclass were understood by it. I came up with the
annoying error "message not understood". I wrote into the previously
redefined "doButtonAction" method some possibilities, like
"MyTextField contents: 'Hello'" or "MyTextField newContentsFrom:
'Hello'" or even not data setting but query messages like 'contents'
or 'currentDataValue' without any success. I thought that inheritance
is simply not working so I even tried to redefine the text field's
subclass message and send back the message to the superclass with
"super contents: 'Hello' '. No success, either.

I think Squeak is a very nice platform but conventional programmers
will have their hair raised up ;-) with the vastly underdocumented
Morphic. Each tutorial picks a bells-and-whistles single morph to
sing, turn or gallop around ;-) (I know, I know: Squeak is a
schoolboy-oriented environment... ) via scripting or through Workspace
direct manipulation but neither tutorial mentions how to set up
conventional interaction like building dialog boxes, data entry forms;
how to "wire in" keyboard navigation between data entry widgets (e.g.
tabbing cycle) etc.

I would be very thankful if someone would give me some hints in this
direction.


Best wishes:
Geza



More information about the Squeak-dev mailing list