1

If I have a morph that contains submorphs, and I delete it, what messages get sent to the submorphs? delete is not being sent.

Here is the situation. I have a container Morph (not subclassed) which holds some submorphs of class MyMorph. After I open the container Morph in world, I close it (from the Morphic halo, or by sending it delete from an inspector. I want the MyMorphs to do something at that time. But I don’t want to make a subclass just for the container Morph. (If I did that, I could just handle delete and have it send some message to each MyMorph). So, is there some message that does get sent by the Morph to each of its submorphs when handling delete?

Paul Richter
  • 6,154
  • 2
  • 20
  • 22
  • What do you mean with „and I delete it“? When you delete a morph „A“ from it’s owner and the deleted morph „A" has submorphs of it’s own, they remain submorphs of „A“, whether you delete „A“ from it’s owner or not. – MartinW Aug 28 '14 at 06:58

1 Answers1

2

Use the intoWorld: / outOfWorld: mechanism.

For an example see MorphTest>>testIntoWorldDeleteOutOfWorld (which uses TestInWorldMorph).

codefrau
  • 4,583
  • 17
  • 17
  • Thank you. I found out on my own that outOfWorld: was what I needed. It's good to know that's what SO's experts recommend as well! – Paul Richter Aug 29 '14 at 13:02