Link start spot on big rectangle node

How can a link be started from the mousedown position on node rather then it always trying to start it in the middle
For example I have a rectangle as node template (see below) with portID ="", linkable from & to true, linkto = topside, linkfrom=bottomside, and when user clicks on this rectangle at point a I want the link to start from point a and not where V is.


| a |
---------------------V---------------------

Also the same for linking to this node , whenever user tries to link to it, that link always terminates in the middle how can I set that to be the spot where mouse is on the node.

By setting the attached “port” properties go:Node.FromSpot and ToSpot, you are declaring where links should connect to that port.

In your example, you have declared that links coming from that node will always start along the bottom edge of the rectangle. When there’s only one link, that will be in the middle.

Did you want the link to always connect to the node/port at point a?

Did you want each drawn link to keep their own starting point, which is probably a different point in the rectangle than point a?

If so, then you’ll need to customize the Diagram.LinkingTool to assign Link.Route.FromSpot on both the TemporaryLink and the real Link if the linking operation succeeds. You can do the former in an override of DraggingTool.DoActivate. You can do the latter in a Diagram.LinkDrawn event handler.

In both cases you’ll need to compute the Spot to use based on the Diagram.FirstMousePointInModel’s relative position in the Link.FromNode.GetElementBounds(Link.FromPort).

Do you mean LinkingTool.DoActivate?

Oops, yes, I meant LinkingTool.