diff --git a/public/litegraph.d.ts b/public/litegraph.d.ts index 7d11437797..f9aa051be7 100644 --- a/public/litegraph.d.ts +++ b/public/litegraph.d.ts @@ -166,12 +166,19 @@ export type LinkReleaseContextExtended = { links: ConnectingLink[]; }; -export type LiteGraphCanvasEventType = "empty-release" | "empty-double-click"; +export type LiteGraphCanvasEventType = "empty-release" | "empty-double-click" | "group-double-click"; export type LiteGraphCanvasEvent = CustomEvent<{ subType: string; - originalEvent: Event, + originalEvent: Event; linkReleaseContext?: LinkReleaseContextExtended; + group?: LGraphGroup; +}>; + +export type LiteGraphCanvasGroupEvent = CustomEvent<{ + subType: "group-double-click"; + originalEvent: MouseEvent; + group: LGraphGroup; }>; export const LiteGraph: { @@ -1121,6 +1128,11 @@ export declare class LGraphGroup { private _bounding: Vector4; color: string; font: string; + size: Vector2; + pos: Vector2; + font_size: number; + + get titleHeight(): number; configure(o: SerializedLGraphGroup): void; serialize(): SerializedLGraphGroup; diff --git a/src/litegraph.js b/src/litegraph.js index 729e759b73..f04b9ddeac 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -4844,6 +4844,10 @@ const globalExport = {}; }); } + get titleHeight() { + return this.font_size * 1.4; + } + configure(o) { this.title = o.title; this._bounding.set(o.bounding); @@ -4925,16 +4929,14 @@ const globalExport = {}; }; }, { left: Infinity, top: Infinity, right: -Infinity, bottom: -Infinity }); - const groupTitleHeight = Math.round(this.font_size * 1.4); - this.pos = [ bounds.left - padding, - bounds.top - padding - groupTitleHeight + bounds.top - padding - this.titleHeight ]; this.size = [ bounds.right - bounds.left + padding * 2, - bounds.bottom - bounds.top + padding * 2 + groupTitleHeight + bounds.bottom - bounds.top + padding * 2 + this.titleHeight ]; } } @@ -7048,9 +7050,22 @@ const globalExport = {}; } else { this.selected_group.recomputeInsideNodes(); } - } - if (is_double_click && !this.read_only) { + if (is_double_click) { + this.canvas.dispatchEvent(new CustomEvent( + "litegraph:canvas", + { + bubbles: true, + detail: { + subType: "group-double-click", + originalEvent: e, + group: this.selected_group, + } + } + )); + } + } else if (is_double_click && !this.read_only) { + // Double click within group should not trigger the searchbox. if (this.allow_searchbox) { this.showSearchBox(e); e.preventDefault();