Skip to content

Commit 85b831d

Browse files
webfilteredhuchenlei
authored andcommitted
Add node disconnect shortcuts (#31)
* Fix loop break missing * Fix logic - cannot reconnect AND disconnect * Add ctrl + alt + click to disconnect nodes Adds disconnect feature and very minor bug fixes (in separate commits): - Ctrl + Alt + Click: Disconnect an input or output - Ctrl + Alt + Click & Drag: Rewire any input/output to another node with a single click - Added LiteGraph setting, on by default. 6036: skip_action = true Not sure why skip_action was set to true, here. It prevents disconnect and drag to a new output on the same click, so I've included it in the main commit. Ideally, this should be controlled by a consumer hook, e.g. onDisconnectInput.
1 parent 6126ebc commit 85b831d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/litegraph.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112

113113
shift_click_do_break_link_from: false, // [false!] prefer false if results too easy to break links - implement with ALT or TODO custom keys
114114
click_do_break_link_to: false, // [false!]prefer false, way too easy to break links
115+
ctrl_alt_click_do_break_link: true, // [true!] who accidentally ctrl-alt-clicks on an in/output? nobody! that's who!
115116

116117
search_hide_on_mouse_leave: true, // [false on mobile] better true if not touch device, TODO add an helper/listener to close if false
117118
search_filter_enabled: false, // [true!] enable filtering slots type in the search widget, !requires auto_load_slot_types or manual set registered_slot_[in/out]_types and slot_types_[in/out]
@@ -5907,7 +5908,7 @@ LGraphNode.prototype.executeAction = function(action)
59075908
//left button mouse / single finger
59085909
if (e.which == 1 && !this.pointer_is_double)
59095910
{
5910-
if (e.ctrlKey)
5911+
if (e.ctrlKey && !e.altKey)
59115912
{
59125913
this.dragging_rectangle = new Float32Array(4);
59135914
this.dragging_rectangle[0] = e.canvasX;
@@ -5918,7 +5919,7 @@ LGraphNode.prototype.executeAction = function(action)
59185919
}
59195920

59205921
// clone node ALT dragging
5921-
if (LiteGraph.alt_drag_do_clone_nodes && e.altKey && node && this.allow_interaction && !skip_action && !this.read_only)
5922+
if (LiteGraph.alt_drag_do_clone_nodes && e.altKey && !e.ctrlKey && node && this.allow_interaction && !skip_action && !this.read_only)
59225923
{
59235924
const cloned = node.clone()
59245925
if (cloned) {
@@ -5984,6 +5985,10 @@ LGraphNode.prototype.executeAction = function(action)
59845985
if (e.shiftKey) {
59855986
node.disconnectOutput(i);
59865987
}
5988+
} else if (LiteGraph.ctrl_alt_click_do_break_link) {
5989+
if (e.ctrlKey && e.altKey && !e.shiftKey) {
5990+
node.disconnectOutput(i);
5991+
}
59875992
}
59885993

59895994
if (is_double_click) {
@@ -6031,15 +6036,9 @@ LGraphNode.prototype.executeAction = function(action)
60316036
var link_info = this.graph.links[
60326037
input.link
60336038
]; //before disconnecting
6034-
if (LiteGraph.click_do_break_link_to){
6039+
if (LiteGraph.click_do_break_link_to || (LiteGraph.ctrl_alt_click_do_break_link && e.ctrlKey && e.altKey && !e.shiftKey)){
60356040
node.disconnectInput(i);
6036-
this.dirty_bgcanvas = true;
6037-
skip_action = true;
6038-
}else{
6039-
// do same action as has not node ?
6040-
}
6041-
6042-
if (
6041+
} else if (
60436042
this.allow_reconnect_links ||
60446043
//this.move_destination_link_without_shift ||
60456044
e.shiftKey
@@ -6059,6 +6058,8 @@ LGraphNode.prototype.executeAction = function(action)
60596058

60606059
this.dirty_bgcanvas = true;
60616060
skip_action = true;
6061+
}else{
6062+
// do same action as has not node ?
60626063
}
60636064

60646065

@@ -6077,6 +6078,8 @@ LGraphNode.prototype.executeAction = function(action)
60776078
this.dirty_bgcanvas = true;
60786079
skip_action = true;
60796080
}
6081+
6082+
break;
60806083
}
60816084
}
60826085
}

0 commit comments

Comments
 (0)