This could be my code of course. I have a subclass of NCConstraintMorph. When I move the morph it is attached to it moves as expected. When I drag it it stays where I drop it, even if that is not where it is constrained to be. When I move the input object, it again moves to where it should be. Is there something I should be doing to make it truly constrained to the input object? I can see the value in letting it be away from the input during the drag, but when I let go of it in space, I want it to snap back to the input object. When I let go over another object I want it to attach to that object. The connector ends do something similar to what I want when they are dragged from one object to another, but they allow themselves to be dropped in empty space, which I do not want. I will look at the connector end morph for a clue.
Michael
On Friday 24 December 2004 7:32 pm, Michael Latta wrote:
This could be my code of course. I have a subclass of NCConstraintMorph. When I move the morph it is attached to it moves as expected. When I drag it it stays where I drop it, even if that is not where it is constrained to be.
When you drop it, it reconnects or disconnects depending on where you dropped it. This is how you reconnect Connectors and move labels.
When I move the input object, it again moves to where it should be. Is there something I should be doing to make it truly constrained to the input object?
Sure. Just make it locked so it can't respond to user input.
I can see the value in letting it be away from the input during the drag, but when I let go of it in space, I want it to snap back to the input object. When I let go over another object I want it to attach to that object. The connector ends do something similar to what I want when they are dragged from one object to another, but they allow themselves to be dropped in empty space, which I do not want. I will look at the connector end morph for a clue.
The connector end morphs don't respond to user input; all of the user input is grabbed by the connector. Which responds to clicks near its ends as requests to grab the end, so it disconnects the end and attaches it to the hand so you can drop it elsewhere.
So are you trying to replace the connector ends or are you trying to do something else with the NCConstraintMorph? It sounds like you don't really want them grabbable.
On Dec 24, 2004, at 9:45 PM, Ned Konz wrote:
On Friday 24 December 2004 7:32 pm, Michael Latta wrote:
This could be my code of course. I have a subclass of NCConstraintMorph. When I move the morph it is attached to it moves as expected. When I drag it it stays where I drop it, even if that is not where it is constrained to be.
When you drop it, it reconnects or disconnects depending on where you dropped it. This is how you reconnect Connectors and move labels.
Currently my shapes are staying connected to the object they were attached to, even if dragged outside their space. Is there something I should override to make them attach/detach based on where they are dropped?
When I move the input object, it again moves to where it should be. Is there something I should be doing to make it truly constrained to the input object?
Sure. Just make it locked so it can't respond to user input.
I want the user to be able to drag the shape. I just want it to snap back if left on the playfield.
I can see the value in letting it be away from the input during the drag, but when I let go of it in space, I want it to snap back to the input object. When I let go over another object I want it to attach to that object. The connector ends do something similar to what I want when they are dragged from one object to another, but they allow themselves to be dropped in empty space, which I do not want. I will look at the connector end morph for a clue.
The connector end morphs don't respond to user input; all of the user input is grabbed by the connector. Which responds to clicks near its ends as requests to grab the end, so it disconnects the end and attaches it to the hand so you can drop it elsewhere.
Ok. I will look there for the connect/disconnect logic. Thanks.
So are you trying to replace the connector ends or are you trying to do something else with the NCConstraintMorph? It sounds like you don't really want them grabbable.
I am trying to do Ports. These are shapes attached to the edges of shapes, that then can have connections to them. I want to be able to drag them to different parts of the shape edge they are on, or to the edge of a different shape, and have them move to that shape. If they get left in free space, they should snap back. Possibly they should only snap back if within some proximity, or they should provide feedback like connection ends do to make it clear if they are attaching. I guess I need to look at the connection more for that logic too.
Thanks, Michael
-- Ned Konz http://bike-nomad.com/squeak/
On Friday 24 December 2004 10:23 pm, Michael Latta wrote:
I am trying to do Ports. These are shapes attached to the edges of shapes, that then can have connections to them. I want to be able to drag them to different parts of the shape edge they are on, or to the edge of a different shape, and have them move to that shape. If they get left in free space, they should snap back. Possibly they should only snap back if within some proximity, or they should provide feedback like connection ends do to make it clear if they are attaching. I guess I need to look at the connection more for that
Then why are you using constraintMorphs? If they're going to have connections to them (which are implemented using constraintMorphs), why would you need the dynamic re-positioning of the constraintMorph in the connection target as well?
Take a look at the Squeakland image to see where Connectors 2 is now (I know, I've got to get a 3.8 version out!). I've added support for connection to submorphs that have the #wantsConnectionWhenEmbedded property set. So you don't have to do anything special to make ports. Just embed submorphs with that property. They don't even have to be anything special or have any special behavior.
Thanks. Yes I guess I do not need the dynamic constraint aspect for ports. In our current diagram design, all layout is by constraints, so it looked like this was a reasonable way to make ports stay on the edges of the shape. I will change it so that they are embedded into the shape instead.
Michael
On Dec 25, 2004, at 1:29 AM, Ned Konz wrote:
On Friday 24 December 2004 10:23 pm, Michael Latta wrote:
I am trying to do Ports. These are shapes attached to the edges of shapes, that then can have connections to them. I want to be able to drag them to different parts of the shape edge they are on, or to the edge of a different shape, and have them move to that shape. If they get left in free space, they should snap back. Possibly they should only snap back if within some proximity, or they should provide feedback like connection ends do to make it clear if they are attaching. I guess I need to look at the connection more for that
Then why are you using constraintMorphs? If they're going to have connections to them (which are implemented using constraintMorphs), why would you need the dynamic re-positioning of the constraintMorph in the connection target as well?
Take a look at the Squeakland image to see where Connectors 2 is now (I know, I've got to get a 3.8 version out!). I've added support for connection to submorphs that have the #wantsConnectionWhenEmbedded property set. So you don't have to do anything special to make ports. Just embed submorphs with that property. They don't even have to be anything special or have any special behavior.
-- Ned Konz http://bike-nomad.com/squeak/
squeak-dev@lists.squeakfoundation.org