From f6679f936b4910a36ec950055069799b90c0dac0 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Mon, 26 Aug 2024 22:17:27 -0400 Subject: [PATCH 1/2] Add onNodeTitleDblClick hook --- public/litegraph.d.ts | 24 ++++++++++++++++++++++++ src/litegraph.js | 9 +++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/public/litegraph.d.ts b/public/litegraph.d.ts index eaa1f819..64b67e3d 100644 --- a/public/litegraph.d.ts +++ b/public/litegraph.d.ts @@ -994,6 +994,30 @@ export declare class LGraphNode { ): void; onKey?(event: KeyboardEvent, pos: Vector2, graphCanvas: LGraphCanvas): void; + onDblClick?( + event: MouseEvent, + pos: Vector2, + graphCanvas: LGraphCanvas + ): void; + + onNodeTitleDblClick?( + event: MouseEvent, + pos: Vector2, + graphCanvas: LGraphCanvas + ): void; + + onInputDblClick?( + event: MouseEvent, + pos: Vector2, + graphCanvas: LGraphCanvas + ): void; + + onOutputDblClick?( + event: MouseEvent, + pos: Vector2, + graphCanvas: LGraphCanvas + ): void; + /** Called by `LGraphCanvas.selectNodes` */ onSelected?(): void; /** Called by `LGraphCanvas.deselectNode` */ diff --git a/src/litegraph.js b/src/litegraph.js index 2fce4966..e43e69db 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -2317,6 +2317,7 @@ const globalExport = {}; + onGetOutputs: returns an array of possible outputs + onBounding: in case this node has a bigger bounding than the node itself (the callback receives the bounding as [x,y,w,h]) + onDblClick: double clicked in the node + + onNodeTitleDblClick: double clicked in the node title + onInputDblClick: input slot double clicked (can be used to automatically create a node connected) + onOutputDblClick: output slot double clicked (can be used to automatically create a node connected) + onConfigure: called after the node has been configured @@ -5956,7 +5957,7 @@ LGraphNode.prototype.executeAction = function(action) if (is_double_click) { if (node.onOutputDblClick) { - node.onOutputDblClick(i, e); + node.onOutputDblClick(i, e, this); } } else { if (node.onOutputClick) { @@ -5987,7 +5988,7 @@ LGraphNode.prototype.executeAction = function(action) ) { if (is_double_click) { if (node.onInputDblClick) { - node.onInputDblClick(i, e); + node.onInputDblClick(i, e, this); } } else { if (node.onInputClick) { @@ -6072,6 +6073,10 @@ LGraphNode.prototype.executeAction = function(action) //double clicking if (this.allow_interaction && is_double_click && this.selected_nodes[node.id]) { + //check if it's a double click on the title bar + if (pos[1] < LiteGraph.NODE_TITLE_HEIGHT) { + node?.onNodeTitleDblClick(e, pos, this); + } //double click node if (node.onDblClick) { node.onDblClick( e, pos, this ); From cd79a8a698151844e0111647d756c4355eb91263 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Mon, 26 Aug 2024 22:18:18 -0400 Subject: [PATCH 2/2] nit --- src/litegraph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/litegraph.js b/src/litegraph.js index e43e69db..09895522 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -2317,7 +2317,7 @@ const globalExport = {}; + onGetOutputs: returns an array of possible outputs + onBounding: in case this node has a bigger bounding than the node itself (the callback receives the bounding as [x,y,w,h]) + onDblClick: double clicked in the node - + onNodeTitleDblClick: double clicked in the node title + + onNodeTitleDblClick: double clicked in the node title + onInputDblClick: input slot double clicked (can be used to automatically create a node connected) + onOutputDblClick: output slot double clicked (can be used to automatically create a node connected) + onConfigure: called after the node has been configured