linkValidation and temporaryToNode

Hello all,

I use linkingTool.linkValidation to authorize or not a link between two nodes. I would like to change nodes color during temporaryLink. When I draw a link to a valid “to node”, the stroke node take green color, but when I draw a link to a unvalid “to node”, nothing append. Is there a way to do this?

Best regards

Could you explain what you’re looking to do more exactly?

Using linkValidation will mean that some ports are found acceptable and others are not. You can use LinkingTool.portTargeted to change the ports it might connect to, but this won’t include changing the ports of objects you cannot connect to.

If you simply wanted to style the link based on whether or not the port was valid, you can just change the temporaryLink as different ports are targeted. Set myDiagram.toolManager.linkingTool.portTargeted to be a function that modifies the myDiagram.toolManager.linkingTool.temporaryLink.