I used to have a PasteUpMorph with a couple of embedded submorphs. The submorphs were connected via connectors. No problem so far.
Then I wanted to connect some of the PasteUpMorphs (the containers) and realized, that they don't accept connectors. So I thought: lets turn them into plain rectangeles. Now I *could* connect the Containers but could no longer connect the Morphs inside the Container.
Am I attempting a logically impossible thing ? Or is there an easy solution ?
On Wednesday 30 April 2003 05:48 pm, Martin Drautzburg wrote:
I used to have a PasteUpMorph with a couple of embedded submorphs. The submorphs were connected via connectors. No problem so far.
Then I wanted to connect some of the PasteUpMorphs (the containers) and realized, that they don't accept connectors. So I thought: lets turn them into plain rectangeles. Now I *could* connect the Containers but could no longer connect the Morphs inside the Container.
Am I attempting a logically impossible thing ?
No. It's just that normally, PUMs act as containers, and we don't want to connect to them (see for instance my CompositeStateMorph, which uses a PUM inside).
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.
Ned Konz ned@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.
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.
On Thursday 01 May 2003 12:38 pm, Martin Drautzburg wrote:
Ned Konz ned@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.
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
squeak-dev@lists.squeakfoundation.org