Hi all, I am struggling with this. I need to allow the user to lock a node or link in place in the drawing.
I am using Orthogonal routing with go.Link.AvoidsNodes.
Expanding on the intro Links topic I am doing this:
diagram.nodeTemplate =
$(go.Node, "Auto",
new go.Binding("location", "loc", go.Point.parse),
new go.Binding("movable", "lockPosition", function (p, s) { //my binding to the lockPosition property we are trying to implement for nodes
s.resizable = !p;
s.rotatable = !p;
return !p;
}),
$(go.Shape, "RoundedRectangle", { fill: "lightgray" }),
$(go.TextBlock, { margin: 5 },
new go.Binding("text", "key"))
);
diagram.linkTemplate =
$(go.Link,
{ routing: go.Link.AvoidsNodes }, // link route should avoid nodes
new go.Binding("movable", "lockPosition", function (p, s) { //my binding to the lockPosition property we are trying to implement for links
s.reshapable = !p;
s.resegmentable = !p;
s.relinkableFrom = !p;
s.relinkableTo = !p;
return !p;
}),
$(go.Shape),
$(go.Shape, { toArrow: "Standard" })
);
var nodeDataArray = [
{ key: "Alpha", loc: "0 0" , lockPosition: true},
{ key: "Beta", loc: "250 40" , lockPosition: true},
{ key: "Gamma", loc: "100 0" },
{ key: "Delta", loc: "75 50" },
{ key: "Epsilon", loc: "150 30" }
];
var linkDataArray = [
{ from: "Alpha", to: "Beta", lockPosition:true }
];
diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
This kind of works until one of the unlocked nodes is dropped on or near our lockPosition link. Then the link is invalidated and redrawn.
I can’t seem to figure out how to block this behavior.
Any help would be appreciated.
Thanks!