How do you make a button Morph tell three StringMorphs to change their contents?
Philippe de Rochambeau
Philippe de Rochambeau writes:
How do you make a button Morph tell three StringMorphs to change their contents?
Philippe de Rochambeau
You can create create some other object, perhaps a Morph, which knows how to tell the other three StringMorphs what to do when it gets a signal from the button.
Lex
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@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
squeak-dev@lists.squeakfoundation.org