这是我正在使用的节点模板:
$(go.Node, "Auto",
{
deletable: false,
selectionAdorned: false
},
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
$(go.Shape, "Terminator",
{
fill: "#f8da07", strokeWidth: 2, minSize: new go.Size(90, 40), portId: "", cursor: "pointer", stroke: '#000000', fromLinkable: true,
toLinkable: false, fromLinkableSelfNode: false, toLinkableSelfNode: false, fromLinkableDuplicates: false, toLinkableDuplicates: false, fromMaxLinks: 1
},
new go.Binding("figure"),
new go.Binding("fill", "color"),
new go.Binding("fill", "isSelected", function(sel) {
return sel ? "#e1e1e1" : [selfColor];
}).ofObject()),
{
click: (e, obj) => {
clickNode(e, obj);
}
},
$(go.TextBlock,
{
stroke: "#000000", margin: 4, editable: false, font: "bold 12pt sans-serif", isMultiline: true
},
new go.Binding("text").makeTwoWay())
);
你可以看到节点的默认颜色是#f8da07,但它实际上是由节点自身颜色属性用“new go.Binding("fill", "color")”这一行写入的。
事实上,我无法知道哪个是当前选择的节点的颜色代码。
我希望能够在选择它时将节点的颜色更改为“#e1e1e1”,但我也希望它在不 -(不是“#f8da07”)时改回旧颜色。
有没有合适的方法来做到这一点?
任何帮助将不胜感激!谢谢
侃侃尔雅
相关分类