Skip to content

Commit 220d630

Browse files
committed
Add selection subtracting for node graph
1 parent d919dfe commit 220d630

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
966966
}
967967

968968
// Clicked on the graph background so we box select
969-
if !shift_click {
969+
if !shift_click && !alt_click {
970970
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: Vec::new() })
971971
}
972972
self.box_selection_start = Some((node_graph_point, false));
@@ -1921,12 +1921,13 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
19211921
.transform_point2(ipp.mouse.position);
19221922

19231923
let shift = ipp.keyboard.get(Key::Shift as usize);
1924+
let alt = ipp.keyboard.get(Key::Alt as usize);
19241925
let Some(selected_nodes) = network_interface.selected_nodes_in_nested_network(selection_network_path) else {
19251926
log::error!("Could not get selected nodes in UpdateBoxSelection");
19261927
return;
19271928
};
19281929
let previous_selection = selected_nodes.selected_nodes_ref().iter().cloned().collect::<HashSet<_>>();
1929-
let mut nodes = if shift {
1930+
let mut nodes = if shift || alt {
19301931
selected_nodes.selected_nodes_ref().iter().cloned().collect::<HashSet<_>>()
19311932
} else {
19321933
HashSet::new()
@@ -1939,7 +1940,11 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
19391940
};
19401941
let quad = Quad::from_box([box_selection_start, box_selection_end_graph]);
19411942
if click_targets.node_click_target.intersect_path(|| quad.to_lines(), DAffine2::IDENTITY) {
1942-
nodes.insert(node_id);
1943+
if alt {
1944+
nodes.remove(&node_id);
1945+
} else {
1946+
nodes.insert(node_id);
1947+
}
19431948
}
19441949
}
19451950
if nodes != previous_selection {
@@ -2734,7 +2739,11 @@ impl NodeGraphMessageHandler {
27342739
let mut hint_data = HintData(vec![
27352740
HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, "Add Node")]),
27362741
HintGroup(vec![HintInfo::mouse(MouseMotion::Lmb, "Select Node"), HintInfo::keys([Key::Shift], "Extend").prepend_plus()]),
2737-
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"), HintInfo::keys([Key::Shift], "Extend").prepend_plus()]),
2742+
HintGroup(vec![
2743+
HintInfo::mouse(MouseMotion::LmbDrag, "Select Area"),
2744+
HintInfo::keys([Key::Shift], "Extend").prepend_plus(),
2745+
HintInfo::keys([Key::Alt], "Subtract").prepend_plus(),
2746+
]),
27382747
]);
27392748
if self.has_selection {
27402749
hint_data.0.extend([

0 commit comments

Comments
 (0)