diff --git a/web/project_key.js b/web/project_key.js index 325daca..04eeed2 100644 --- a/web/project_key.js +++ b/web/project_key.js @@ -201,6 +201,35 @@ app.registerExtension({ app.graph?.setDirtyCanvas(true, true); }; + // --- Highlight all ProjectKey nodes sharing the same key_name on select --- + nodeType.prototype.onSelected = function () { + const keyWidget = this.widgets?.find(w => w.name === "key_name"); + const myKey = keyWidget?.value; + if (!myKey || !this.graph) return; + for (const node of this.graph._nodes) { + if (node === this || node.type !== "ProjectKey") continue; + const kw = node.widgets?.find(w => w.name === "key_name"); + if (kw?.value !== myKey) continue; + node._savedColor = node.color; + node._savedBgColor = node.bgcolor; + node.color = "#c8a000"; + node.bgcolor = "#4a3800"; + } + app.graph?.setDirtyCanvas(true, true); + }; + + nodeType.prototype.onDeselected = function () { + if (!this.graph) return; + for (const node of this.graph._nodes) { + if (node.type !== "ProjectKey" || !("_savedColor" in node)) continue; + node.color = node._savedColor; + node.bgcolor = node._savedBgColor; + delete node._savedColor; + delete node._savedBgColor; + } + app.graph?.setDirtyCanvas(true, true); + }; + // --- Sync config on click (lazy, no key refresh to avoid race) --- const origOnMouseDown = nodeType.prototype.onMouseDown; nodeType.prototype.onMouseDown = function (e, localPos, graphCanvas) {