Morphic question

Norton, Chris chrisn at Kronos.com
Thu Jul 13 14:59:54 UTC 2000


Hi Michael.

[Of course, this isn't the only way to do what you want...]

What you need to do is to create an instance variable in your model class to
hold your button morph and an accessor method that can be used to directly
query the morph in question.  If you aren't using a model class (i.e. if
you're just using morphs), then my suggestion to you is to put an instance
variable on your top level morph class, with an accessor method for that
variable.  Then when you construct your morph, just assign the variable to
your button morph (or you can just point to the button's script).  At a
later time, you can directly access the button morph via the accessor
method.

And if that was as clear as mud...  well, let's get a bit clearer.

1.  Choose the morph that you want to be the owner (e.g. a SystemWindow or
perhaps a PasteUpMorph).  This morph could be any kind of morph that is the
"king" of the little empire you're building.
2.  Create a subclass of that morph and call it whatever you want.
3.  Add an instance variable to the subclass of that morph called
"scriptButton"
4.  In the constructor code for the morph, just prior to calling "addMorph:"
to your button, assign the button to the scriptButton variable.
5.  You can then use the accessor selector for the "scriptButton" to
directly manipulate the button morph and it's contents.

Cheers,

---==> Chris






More information about the Squeak-dev mailing list