[Newbies] Morphic Questions

Michael van der Gulik mikevdg at gulik.co.nz
Fri Feb 15 08:55:55 UTC 2008

Hi Jeffrey.

24 hours and no answer, so I'll have a crack at your questions.

Jeffrey Straszheim wrote:
> I have some basic intro questions on Morphic.  I'm digging through the
> source code, and reading what I can find on the web, but it is quite a
> lot to take in.
> 1. Messages
> There seem to be at least 2 ways to handle messages with Morphic.  The
> subclassing way, overriding methods such as *handlesMouseDown* and so
> on, and *on:send:to:* way.  What are the differences between the two,
> and why would I prefer one over the other?

Unless you come across problems, either way is good.

A quick look at the code shows that if you override methods, you'll be
overriding the implementation used by on:send:to to implement message
sending. It seems your implementation would run faster if you override
the methods.

You might want to use on:send:to if you want your event handling logic
to be in another object.

> 2. MorphicModel
> The MorphicModel class appears to be for morphs that implement the
> view side of MVC.  However, I find the source rather confusing.  What
> on earth is a *slotSelector*, for instance?  And a method like
> *compileAccessForSlot* just leaves me baffled.  What is this class
> for, and are there any simple examples of its use?

Welcome to Squeak. You might find a lot of the source quite confusing;
there are a lot of ancient relics, failed experiments and red herrings
in the image. Just try to understand only as much as you need; trying to
understand more will leave you either confused or disgusted.

Note firstly that MorphicModel is a superclass of a whole host of other
classes - open up the hierarchy browser and see! I believe it represents
to some degree the "model" of the model-view-controller paradigm that
Morphic was written to be so blissfully unaware of.

As with a slot - never heard of them, and the source code is pretty
non-obvious. It messes with reflection, so it's probably dodgy code.

> 3. PasteUpMorph
> I know that the screen background is a PasteUpMorph, but I see them
> mentioned elsewhere from time to time.  What exactly is a
> PasteUpMorph?  Would I ever want to use one?  Is there a simple example?

The PasteUpMorph class in Squeak 3.9 has a pretty good description. Try

PasteUpMorph newWorldTesting

Often you'll find test methods on the class side. These can be useful
for just playing with the code to see what it does. The BitBlt class
tends to be pretty fascinating in this regard :-).

Also, again, look at the inheritance hierarchy (the "hierarchy" button
in the browser) and you'll see its the superclass of a bunch of other
interesting looking classes.

Don't forget to visit us on IRC at #squeak. It's often quiet for long
periods, but people do come and go and we like newbies there.


More information about the Beginners mailing list