Sending messages

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending messages

James O'Brien-3
I would like to use a SimpleButtonMorph that, when clicked on, will
cause some text to appear in a TextMorph. Any suggestions on how to do this?
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Sending messages

Sean P. DeNigris
Administrator
James O'Brien-3 wrote
I would like to use a SimpleButtonMorph that, when clicked on, will
cause some text to appear in a TextMorph. Any suggestions on how to do this?
If you mean an existing TextMorph, see SimpleButtonMorph's class comment. There is an example that you can easily adapt.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Sending messages

James O'Brien-3
Yes, there is an existing TextMorph. Using the first example in the
SimpleButtonMorph's class comment, would the target be the TextMorph? If
so, how is the correct TextMorph identified if there are two or more of
them?

On 12/29/11 2:21 PM, Sean P. DeNigris wrote:

> James O'Brien-3 wrote
>> I would like to use a SimpleButtonMorph that, when clicked on, will
>> cause some text to appear in a TextMorph. Any suggestions on how to do
>> this?
>>
> If you mean an existing TextMorph, see SimpleButtonMorph's class comment.
> There is an example that you can easily adapt.
>
> --
> View this message in context:http://forum.world.st/Sending-messages-tp4244002p4244142.html
> Sent from the Squeak - Beginners mailing list archive at Nabble.com.
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Sending messages

Sean P. DeNigris
Administrator
James O'Brien-3 wrote
SimpleButtonMorph's class comment, would the target be the TextMorph? If
so, how is the correct TextMorph identified if there are two or more of
them?
Yes, you'd need access to the TextMorph instance, and write something like:
button := SimpleButtonMorph newWithLabel: 'change text'.
button
        target: tm;
                actionSelector: #contents:;
                arguments: #('new text');
                openInWorld

If you didn't create the TextMorph and can't get access to it, you can find it by searching through the world's submorphs (recursively if nec.)
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Sending messages

Ben Coman
Sean P. DeNigris wrote:
James O'Brien-3 wrote
  
SimpleButtonMorph's class comment, would the target be the TextMorph? If 
so, how is the correct TextMorph identified if there are two or more of 
them?

    

Yes, you'd need access to the TextMorph instance, and write something like:
button := SimpleButtonMorph newWithLabel: 'change text'.
button
	target: tm;
		actionSelector: #contents:;
		arguments: #('new text'); 
		openInWorld

If you didn't create the TextMorph and can't get access to it, you can find
it by searching through the world's submorphs (recursively if nec.)
  
Here is a write up of something interesting I found to access existing morphs
http://blog.openinworld.com/2011/04/workspace-referencing-to-existing-morphs/

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners