[Q}[CONNECTORS] Connecting submorphs

Ned Konz ned at bike-nomad.com
Thu May 1 18:26:42 UTC 2003


On Thursday 01 May 2003 12:38 pm, Martin Drautzburg wrote:
> Ned Konz <ned at bike-nomad.com> writes:
> > > Or is there an easy solution ?
> >
> > Yes. If you have a PUM that should accept connections, just make
> > a subclass that answers true to #Isconnectable.
>
> You mean like this:
>
> 'From Squeak3.5 of ''11 April 2003'' [latest update: #5180] on 1
> May 2003 at 9:23:05 pm'! PasteUpMorph subclass: #Foo
> 	instanceVariableNames: ''
> 	classVariableNames: ''
> 	poolDictionaries: ''
> 	category: 'Dtz-SPM'!
>
> !Foo methodsFor: 'as yet unclassified' stamp: 'dtz 5/1/2003 21:22'!
> isConnectable
>
> 	^ true! !
>
> Then I try to connect it to something with the Connector from the
> Connectors Flap. For some reason #isConnectable does not get
> called. There seems to be more to it.

Yes. Sorry. If you look at NCConnectorMorph>>connectionTargetsAt:for: 
you will see also that the logic there ignores any Morphs that answer 
true to #isPlayfieldLike. So if you also added

	isPlayfieldLike
		^false

to your Foo class it should be connectable.

> How about the other scenario (a RectangleMorph containing another
> RectangleMorph). The conainer seems to eat some crucial events so I
> cannot connect to the inner Rectangle.

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