[Q] Morph owners

Ned Konz ned at bike-nomad.com
Fri Sep 5 15:44:10 UTC 2003


On Thursday 04 September 2003 10:41 pm, Chris Muller wrote:
> I have a composition of Morphs that, when I pick up an inner one
> (e.g., whose owner is not the world), would like to use a
> NCConnector to point to its former owner.
>
> I tried overriding privateOwner: to:
>
>   super privateOwner: aMorph.
>   self resetLines
>
> where I implemented resetLines to do what I want.  It didn't work. 
> It didn't appear to call privateOwner: when I dragged out or even
> dropped onto the current World.
>
> It seems clunky to be overriding this private method anyway.  Is
> there a better way?

Yes. Use #noteNewOwner: to do this.

Morph subclass: #AutoLinkingMorph
	instanceVariableNames: 'priorOwner '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Demo-Ned'

AutoLinkingMorph>>noteNewOwner: newParent
	super noteNewOwner: newParent.
	newParent isHandMorph
		ifTrue: [ (priorOwner notNil and: [ priorOwner isWorldOrHandMorph 
not ]) ifTrue: [
				(NCConnectorMorph fromMorph: priorOwner toMorph: self) 
openInWorld: self world ]]
		ifFalse: [ priorOwner _ newParent ].

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list