Simple Morphs (correction)

Dietmar Krueger dkrueger at rols2.oec.uni-osnabrueck.de
Tue Apr 28 15:25:36 UTC 1998


>Dietmar Krueger wrote:
>>
>
>> >
>> >It only takes 30 seconds:
>> >-Open an empty morphic world.
>> >-Add a TextMorph and a SimpleButtonMorph
>> >-Place the SimpleButtonMorph above the TextMorph!!!
>> >-Choose the following from the popup menu of the SimpleButtonMorph:
>> >--set target
>> >--change action selector (type in: contents)
>> sorry, a small correction:
>> --change action selector (type in: contents:)
>> >--change arguments (type in: 'Hello World')
>> >-Press the button
>> >
>> >Greetings,
>> >Dietmar
>
>
>Many thanks Dietmar. It works!
>
>Now, do I need to subclass SimpleButtonMorph everytime I want to change its
>label, its target, etc? If I plan to have 10 different buttons in my window,
>do I need to create ten different subclasses of SimpleButtonMorph?

No. When you add a Morph to a World then you create an Instance of this
Morph class. Label & targets are only instance variables.

>How do you target several targets; do you simply drop the button on the
>various targets?

You can only have one target. But the target morph can have a Collection of
Morphs/Objects.

>How do you give several selectors to a Morph? For instance, how do you tell
>the ButtonMorph to go fetch the contents of a TextMorph and put them in a
>particular StringMorph?

In this case you can create a subclass of the TextMorph (e.g. MyTextMorph)
with a method that do several things. The button activates this method (of
the instance of MyTextMorph).

>
>Do I need to give my TextMorph a name for the ButtonMorph to be able to get
>its contents before transferring them to the StringMorph?

I don't understand the name part... The ButtonMorph knows an instance of
MyTextMorph (the instance is stored in the instance variable target of the
Button). A MyTextMorph should have an instance variable with the
StringMorph. So it is possible to realize a communication between the
Morphs...

Greetings,
Dietmar





More information about the Squeak-dev mailing list