Change linking snapping behavior and the pink rectangle


Two questions:

  • How can I change the snapping behavior of the linking tool? As you see in the gif the cursor is not even close to the node and yet the link snaps to it.

  • How can I change the pink rectangle around “from” and “to” node when a link is being drawn?

Thanks. May I add two more questions to this?

  • How can I get the node that the link is being connected to when it snaps? temporaryToNode seems to be null and since this is not relinking, the originalToNode is also null.
  • How can I style some nodes while this link is being drawn? I drag a link from A to B and when it snaps to B I wanna run some logic and color some other nodes.

For simple cases you can set LinkingBaseTool.portTargeted.

For more general cases you can override LinkingBaseTool.copyPortProperties and LinkingBaseTool.setNoTargetPortProperties.

Remember that both the LinkingTool and the RelinkingTool are instances of (subclasses of) LinkingBaseTool, so if your app supports relinking, you’ll have to customize both tools.

1 Like

Thank you very much. That was extremely helpful.