Accessing Morphs as objects

Lex Spoon lex at cc.gatech.edu
Sat Jun 8 17:05:00 UTC 2002


Geza Lakner MD <geza67 at freestart.hu> wrote:


> > than you'd expect: scripted actions don't end up in the Morph class,
> > but in a Player subclass with a unique name. The Morph then points to 
> That's sad - thus it is not a 2-way tool :-(
> 

The closest thing I've seen in Morphic is not obvious.  It goes like
this:

	1. Arrange your morphs as desired.
	2. Choose "make own subclass" from the gray halo.

Then you can go from there.  You have a single prototype instance and
you can add methods to its class (which is handily accessible with the
gray halo).

Here are three general directions you can go from here:

	1. Add behavior for mouse events, stepping, redrawing, or whatever else
via "browse morph class".

	2. Work on storing your prototype somewhere, if sticking it in a flap
is not good enough.  You could add a class instance variable (using
"Browse morph class")  and then store your prototype into it using an
inspector.
	
	3. Make instance variables pointing to submorphs that are special in
some way.  For example, you might want to make all the text boxes in
your morph accessible to the main morph with instance variables.  You
can add the variables using a browser, and you can wire it all together
using inspectors.


It's not awesome, but it does preserve the liveness of the system.  In
practice, most everyone seems to rewrite their build code as raw code
once they've played around with it a bit.


-Lex



More information about the Squeak-dev mailing list