Change node style if link is invalid

Hi,

I’m trying to implement a visual indicator if a user tries to make an invalid connection, if a user attempts to make an invalid connection by manually dragging a connection from one node to another I’d like to change the style of the “invalid” node so that the user can easily see the connection is invalid. Is there a way to do this?

First, I should point out that our recommended policy is to prevent users from drawing invalid links. The link validation mechanisms are described at GoJS Validation -- Northwoods Software.

However, I can understand that you might want to have a different policy, where the user can draw any link and that your app highlights invalid links. What you could do is implement a “LinkDrawn” DiagramEvent listener and then modify the DiagramEvent.subject, which will be the new Link, as you like.

If your app supports reconnecting existing links, you will also want to implement a “LinkRelinked” DiagramEvent listener.

The idea is that we will not allow them to draw the invalid link, but we also want the target node to change color (if it’s invalid) whenever the user attempts to drag a connection to it.

There are several plausible alternatives, depending on what you really want to do. Perhaps you want to override LinkingBaseTool | GoJS API. Or maybe you want to override LinkingTool | GoJS API.