diff --git a/graph_node_renderer/deck_renderer_graph_edit.gd b/graph_node_renderer/deck_renderer_graph_edit.gd index 473cb18..aeff7e6 100644 --- a/graph_node_renderer/deck_renderer_graph_edit.gd +++ b/graph_node_renderer/deck_renderer_graph_edit.gd @@ -32,6 +32,7 @@ func _ready() -> void: ) connection_request.connect(attempt_connection) + disconnection_request.connect(attempt_disconnect) func attempt_connection(from_node_name: StringName, from_port: int, to_node_name: StringName, to_port: int) -> void: @@ -43,3 +44,15 @@ func attempt_connection(from_node_name: StringName, from_port: int, to_node_name if deck.connect_nodes(from_node, to_node, from_output, to_input): connect_node(from_node_name, from_port, to_node_name, to_port) + + +func attempt_disconnect(from_node_name: StringName, from_port: int, to_node_name: StringName, to_port: int) -> void: + var from_node: DeckNode = get_node(NodePath(from_node_name)).node + var to_node: DeckNode = get_node(NodePath(to_node_name)).node + + var from_output := from_node.get_global_port_idx_from_output(from_port) + var to_input := to_node.get_global_port_idx_from_input(to_port) + + deck.disconnect_nodes(from_node, to_node, from_output, to_input) + + disconnect_node(from_node_name, from_port, to_node_name, to_port)