From 1c40aad87c7ca51f197005f93367ded1bf1ec94b Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 8 Nov 2024 07:58:49 +1100 Subject: [PATCH] Fix pin not respected by multi-select move (#284) --- src/LGraphCanvas.ts | 2 +- src/LGraphNode.ts | 2 ++ src/interfaces.ts | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index c1be86014..5f9cef140 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -2444,7 +2444,7 @@ export class LGraphCanvas { this.#dirty() function addToSetRecursively(item: Positionable, items: Set): void { - if (items.has(item)) return + if (items.has(item) || item.pinned) return items.add(item) item.children?.forEach(x => addToSetRecursively(x, items)) } diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index 285bda2ad..f8e8da3dd 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -1437,6 +1437,8 @@ export class LGraphNode implements Positionable, IPinnable { } move(deltaX: number, deltaY: number): void { + if (this.pinned) return + this.pos[0] += deltaX this.pos[1] += deltaY } diff --git a/src/interfaces.ts b/src/interfaces.ts index 4ef9311d9..59ee75513 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -24,6 +24,9 @@ export interface Positionable { /** true if this object is part of the selection, otherwise false. */ selected?: boolean + /** See {@link IPinnable.pinned} */ + readonly pinned?: boolean + readonly children?: ReadonlySet /**