From 83cb79530134c39b00c31bdedc6defa00670bd16 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:10:08 +1100 Subject: [PATCH] Fix group deselected on title click (#230) --- src/LGraphCanvas.ts | 2 +- src/LGraphGroup.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index 9dfd2433a..9c053d134 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -2820,7 +2820,7 @@ export class LGraphCanvas { this.visible_nodes ) - if (!node && e.click_time < 300) { + if (!node && e.click_time < 300 && !this.graph.groups.some(x => x.isPointInTitlebar(e.canvasX, e.canvasY))) { this.deselectAllNodes() } diff --git a/src/LGraphGroup.ts b/src/LGraphGroup.ts index 422343dd5..23847e7dc 100644 --- a/src/LGraphGroup.ts +++ b/src/LGraphGroup.ts @@ -3,7 +3,7 @@ import type { LGraph } from "./LGraph" import type { ISerialisedGroup } from "./types/serialisation" import { LiteGraph } from "./litegraph" import { LGraphCanvas } from "./LGraphCanvas" -import { overlapBounding } from "./measure" +import { isInsideRectangle, overlapBounding } from "./measure" import { LGraphNode } from "./LGraphNode" export interface IGraphGroup { @@ -259,6 +259,11 @@ export class LGraphGroup { ] } + isPointInTitlebar(x: number, y: number): boolean { + const b = this._bounding + return isInsideRectangle(x, y, b[0], b[1], b[2], this.titleHeight) + } + isPointInside = LGraphNode.prototype.isPointInside setDirtyCanvas = LGraphNode.prototype.setDirtyCanvas }