How can I embed an object in another "holder"

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

How can I embed an object in another "holder"

Steve Thomas
I'm using Etoys and I want to change and objects "holder"
What is the squeak code to embed it in a different object?

Thanks,
Stephen

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How can I embed an object in another "holder"

K K Subbu
On Monday 28 January 2013 09:54 AM, Steve Thomas wrote:
> I'm using Etoys and I want to change and objects "holder"
> What is the squeak code to embed it in a different object?

You have to detach the morph from its existing owner and then add it to
the destination container. See grabMorph:from and attachMorph: methods
for examples.

Also see senders of addMorph: and its variants addMorphFront:,
addMorphBack: for more examples on how to embed morphs.

A Holder is essentially a PasteUpMorph with some options turned on.
Other variants are Playfield, PartsBin etc.

Regards .. Subbu

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How can I embed an object in another "holder"

Steve Thomas
Thanks Subbu.

I started looking at what you sent and poking around trying to figure out the code, then realized I could do it "the Etoys way" and put the morph back into its previous holder (which can vary and I store in a player variable).
I wound up using a playfield include tile and replacing playfield with the variable used to store the original holder:
self getOrigHolder include: self.

Stephen


On Mon, Jan 28, 2013 at 12:53 AM, K. K. Subramaniam <[hidden email]> wrote:
On Monday 28 January 2013 09:54 AM, Steve Thomas wrote:
I'm using Etoys and I want to change and objects "holder"
What is the squeak code to embed it in a different object?

You have to detach the morph from its existing owner and then add it to the destination container. See grabMorph:from and attachMorph: methods for examples.

Also see senders of addMorph: and its variants addMorphFront:, addMorphBack: for more examples on how to embed morphs.

A Holder is essentially a PasteUpMorph with some options turned on. Other variants are Playfield, PartsBin etc.

Regards .. Subbu



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How can I embed an object in another "holder"

Bert Freudenberg
On 2013-01-28, at 07:31, Steve Thomas <[hidden email]> wrote:

> Thanks Subbu.
>
> I started looking at what you sent and poking around trying to figure out the code, then realized I could do it "the Etoys way" and put the morph back into its previous holder (which can vary and I store in a player variable).
> I wound up using a playfield include tile and replacing playfield with the variable used to store the original holder:
>
> self getOrigHolder include: self.
>
> Stephen

Yep, that's the right way to do it in Etoys. In addition to moving the object, it also ensures it's in view, the holder's cursor gets updated etc.

If you were doing it in plain Morphic, you would do something like

        newContainer addMorph: self

which automatically deletes self from its current container, but does not change the position etc.

- Bert -

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