[Cuis] Copy vs Clone

Ken.Dickey Ken.Dickey at whidbey.com
Wed May 13 17:41:00 CDT 2015


I am seeing a strange behavior.

The simple way to see it is to make a child class of PartsBinMorph.  Call it, say, PartsBinTestMorph.

Add a method #PartsBinTestMorph>>
  aboutToGrab: aMorph

	^aMorph clone "parent has aMorph copy"

WHen I obtain a PartsBinMorph from the new morph menu, then add, say, a ellipse morph, I get the expected behavior.  WHen I "drag the ellipse out", the hand gets a copy of the ellipse and the original ellipse remains where I can see it.

But doing the same thing in a PartsBinTestMorph, I appear to grab the ellipse.

Now it turns out that the original ellipse is still a submorph of the PartsBinTestMorph, but it's morphPosition seems to be set to some random value.

I tried saving the original morphPosition, doing the clone, then resetting the saved morphPosition, but this does not change anything.

Unfortunately, my copy of the blue book is saved in a box somewhere (I am moving), so I don't have a spec for #clone.

Interestingly, this happens both on the ARM and Intel Cog Stack VMs.

Can someone help me out to understand this?

Thanks much,
-KenD




More information about the Cuis mailing list