From 6762f1f33987844a0badc68cbbff57543d60ff14 Mon Sep 17 00:00:00 2001 From: Mohsen Karami Date: Wed, 30 Nov 2022 16:00:34 +0330 Subject: [PATCH 1/2] Allow selecting multi nodes without pressing extra keys --- src/litegraph.d.ts | 2 ++ src/litegraph.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/litegraph.d.ts b/src/litegraph.d.ts index c9fbe0ced0..6629e779ff 100644 --- a/src/litegraph.d.ts +++ b/src/litegraph.d.ts @@ -1142,6 +1142,8 @@ export declare class LGraphCanvas { allow_interaction: boolean; /** allows to change a connection with having to redo it again */ allow_reconnect_links: boolean; + /** allow selecting multi nodes without pressing extra keys */ + multi_select: boolean; /** No effect */ allow_searchbox: boolean; always_render_background: boolean; diff --git a/src/litegraph.js b/src/litegraph.js index 3f0afa0a9a..c0242831e1 100644 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -5202,6 +5202,7 @@ LGraphNode.prototype.executeAction = function(action) this.allow_dragcanvas = true; this.allow_dragnodes = true; this.allow_interaction = true; //allow to control widgets, buttons, collapse, etc + this.multi_select = false; //allow selecting multi nodes without pressing extra keys this.allow_searchbox = true; this.allow_reconnect_links = true; //allows to change a connection with having to redo it again this.align_to_grid = false; //snap to grid @@ -7279,7 +7280,7 @@ LGraphNode.prototype.executeAction = function(action) }; LGraphCanvas.prototype.processNodeSelected = function(node, e) { - this.selectNode(node, e && (e.shiftKey||e.ctrlKey)); + this.selectNode(node, e && (e.shiftKey || e.ctrlKey || this.multi_select)); if (this.onNodeSelected) { this.onNodeSelected(node); } From f62b33d95a0e31bf678d6b62ef74ad673b59402b Mon Sep 17 00:00:00 2001 From: Mohsen Karami Date: Tue, 6 Dec 2022 23:27:33 +0330 Subject: [PATCH 2/2] Add the ability to deselect the selected blocks in multi-select mode --- src/litegraph.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/litegraph.js b/src/litegraph.js index c0242831e1..44366d2cde 100644 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -6053,9 +6053,7 @@ LGraphNode.prototype.executeAction = function(action) this.graph.beforeChange(); this.node_dragged = node; } - if (!this.selected_nodes[node.id]) { - this.processNodeSelected(node, e); - } + this.processNodeSelected(node, e); } this.dirty_canvas = true; @@ -7316,6 +7314,7 @@ LGraphNode.prototype.executeAction = function(action) for (var i in nodes) { var node = nodes[i]; if (node.is_selected) { + this.deselectNode(node); continue; }