a target object a selector to be sent an optional list of arguments for the message when to do the action (on mouse down, repeatedly while down, or on mouse up)
What is a selector?
You can actually set all of these using menu commands. To set the target, put the button over the desired target morph and then use the "set target" menu command on the button.
I can't find any "set target" menu command in the popup menu.
How do you tell a button to change a TextMorph's contents to "Hello World"?
Many thanks.
Philippe de Rochambeau
a target object a selector to be sent an optional list of arguments for the message when to do the action (on mouse down, repeatedly while down, or on mouse up)
What is a selector?
You can actually set all of these using menu commands. To set the target, put the button over the desired target morph and then use the "set target" menu command on the button.
I can't find any "set target" menu command in the popup menu.
How do you tell a button to change a TextMorph's contents to "Hello World"?
Many thanks.
Philippe de Rochambeau
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) --change arguments (type in: 'Hello World') -Press the button
Greetings, Dietmar
a target object a selector to be sent an optional list of arguments for the message when to do the action (on mouse down, repeatedly while down, or on mouse up)
What is a selector?
You can actually set all of these using menu commands. To set the target, put the button over the desired target morph and then use the "set target" menu command on the button.
I can't find any "set target" menu command in the popup menu.
How do you tell a button to change a TextMorph's contents to "Hello World"?
Many thanks.
Philippe de Rochambeau
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
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?
How do you target several targets; do you simply drop the button on the various targets?
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?
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?
Vielen Dank.
Philippe de Rochambeau
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
Dietmar Krueger wrote:
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...
The popup menu lets you name Morphs. I am not sure why.
Philippe de Rochambeau
squeak-dev@lists.squeakfoundation.org