gojs - 选择时更改节点的颜色,否则返回原始颜色?

gojs - Change color of node when selected, but go back to original color otherwise?

这是我正在使用的节点模板:

      $(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")".

事实上,我无法知道哪个是正在 selected 的节点的当前颜色代码。

我希望能够在我 select 时将节点的颜色更改为“#e1e1e1”,但我也希望它在不 - (这不是"#f8da07").

有正确的方法吗?

任何帮助将不胜感激!谢谢

$(go.Shape,
  { fill: "#f8da07" },  // default color
  new go.Binding("fill", "color"),
  new go.Binding("fill", "isSelected", function(sel, shape) {
    return sel ? "#e1e1e1" : shape.part.data.color || "#f8da07";
  }).ofObject()),