[Q}[CONNECTORS] Connecting submorphs

Martin Drautzburg martin.drautzburg at web.de
Thu May 1 23:52:59 UTC 2003


Thanks,

since I have my own subclasses I chose the following:

(1) The containser (aPasteUpMorph) answers false to #isPlayfieldLike
(2) The containser (aPasteUpMorph) answers true to #isConnectable
(3) The elemens in the container answer true to 
        #wantsAttachmentFromEnd:ofConnector:

and it works like a charm.

> Look at Morph>>wantsAttachmentFromEnd: endIndex ofConnector: 
> aConnector
> 
> This contains a number of tests that will keep a Morph from being 
> connectable. In this case, the inner rectangle, (since its owner is 
> not a playfield) will not ordinarily accept connections:
> 
> So what can you do here if you want to connect *both* to a container 
> and its contents?
> 
> - if the container is a bare PasteUpMorph, make it return false from 
> isPlayfieldLike
> - but then its contents won't be connectable, unless they return true 
> to wantsAttachmentFromEnd:ofConnector:
> 
> So the best pattern is probably to do what I did with the 
> CompositeStateMorph:
> 
> - don't use a bare PasteUpMorph as a container, since it won't be 
> connectable. Instead, wrap the PUM in another Morph.
> - Now, both the contents of the PUM and the owner (the top-level 
> Morph) will be connectable.
> 
> This way you don't need any custom classes.
> 
> -- 
> Ned Konz
> http://bike-nomad.com
> GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list