How do you make a Morph communicate with several other Morphs?

Bruce Cohen cohenb at gemstone.com
Wed Apr 29 18:55:04 UTC 1998


>> How do you make a button Morph tell three StringMorphs to change their contents?

I did that while playing with Morphs a while ago, unfortunately I didn't
file out the code or save the image, because I was just noodling around.
But it's pretty simple: create subclass of SimpleButtonMorph, call it
MultiTargetButtonMorph, and code an #initialize method that sets the
target instvar to be a new OrderedCollection.  Then write #addTarget:
and #removeTarget: methods to add and remove elements in the target
Collection (base them on the #setTarget: method in SimpleButtonMenu).
Then you need to add a #addCustomMenuItems:hand: method to put in menu
options for the addTarget and removeTarget methods.

>From there on, it's just like using a SimpleButtonMorph: position the
button over each of the StringMorphs in turn and select addTarget from
its menu, and set the actionSelector and argument to contents: and
'Hello, Universe' or your favorite test string, respectively.
-----------------------------------------------------------------------------
"Only a proper understanding of the constraints imposed by the
properties of our space and of the rich repertoire permitted within
these constraints allow the achievement of a balanced disciplined
freedom."  - Arthur Loeb in "Concepts and Images"
-----------------------------------------------------------------------------
Bruce Cohen,                               |  email: cohenb at gemstone.com
GemStone Systems, Inc.                     |  phone: (503)533-3602
20575 NW Von Neumann Drive                 |  fax:   (503)629-8556
Beaverton, OR USA 97006                    |  web:   http://www.gemstone.com





More information about the Squeak-dev mailing list