You can define a LinkingBaseTool.portTargeted function to modify the temporaryLink. For example, add this code to the General Linking Validation sample:[code] var invalidDashArray = [4, 4]; // the dash pattern to use when there's no valid port to connect to
diagram.toolManager.linkingTool.portTargeted = function(realnode, realport, tempnode, tempport, toend) {
var link = diagram.toolManager.linkingTool.temporaryLink;
var shape = link.elt(0); // assume main Shape is the first element
if (shape instanceof go.Shape) shape.strokeDashArray = (realport ? null : invalidDashArray);
}
diagram.toolManager.relinkingTool.portTargeted = function(realnode, realport, tempnode, tempport, toend) {
var link = diagram.toolManager.relinkingTool.temporaryLink;
var shape = link.elt(0); // assume main Shape is the first element
if (shape instanceof go.Shape) shape.strokeDashArray = (realport ? null : invalidDashArray);
}[/code]
Note that the dashedIfInvalid function just works with the LinkingTool