Skip to content

Commit 0dc0e6a

Browse files
Yuxiang-HuangKeavon
authored andcommitted
Implement proper node graph interaction aborting when pressing Escape
1 parent 2ee8e56 commit 0dc0e6a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::messages::layout::utility_types::widget_prelude::*;
1212
use crate::messages::portfolio::document::data_panel::{DataPanelMessageContext, DataPanelMessageHandler};
1313
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
1414
use crate::messages::portfolio::document::node_graph::NodeGraphMessageContext;
15+
use crate::messages::portfolio::document::node_graph::utility_types::FrontendGraphDataType;
1516
use crate::messages::portfolio::document::overlays::grid_overlays::{grid_overlay, overlay_options};
1617
use crate::messages::portfolio::document::overlays::utility_types::{OverlaysType, OverlaysVisibilitySettings};
1718
use crate::messages::portfolio::document::properties_panel::properties_panel_message_handler::PropertiesPanelMessageContext;
@@ -479,6 +480,20 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
479480
if self.node_graph_handler.drag_start.is_some() {
480481
responses.add(DocumentMessage::AbortTransaction);
481482
self.node_graph_handler.drag_start = None;
483+
}
484+
// Abort box selection
485+
else if self.node_graph_handler.box_selection_start.is_some() {
486+
self.node_graph_handler.box_selection_start = None;
487+
responses.add(NodeGraphMessage::SelectedNodesSet {
488+
nodes: self.node_graph_handler.selection_before_pointer_down.clone(),
489+
});
490+
responses.add(FrontendMessage::UpdateBox { box_selection: None });
491+
} else if self.node_graph_handler.wire_in_progress_from_connector.is_some() {
492+
self.node_graph_handler.wire_in_progress_from_connector = None;
493+
self.node_graph_handler.wire_in_progress_type = FrontendGraphDataType::General;
494+
self.node_graph_handler.wire_in_progress_to_connector = None;
495+
responses.add(DocumentMessage::AbortTransaction);
496+
responses.add(FrontendMessage::UpdateWirePathInProgress { wire_path: None });
482497
} else if self
483498
.node_graph_handler
484499
.context_menu

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ pub struct NodeGraphMessageHandler {
6363
pub drag_start_chain_nodes: Vec<NodeId>,
6464
/// If dragging the background to create a box selection, this stores its starting point in node graph coordinates,
6565
/// plus a flag indicating if it has been dragged since the mousedown began.
66-
box_selection_start: Option<(DVec2, bool)>,
66+
pub box_selection_start: Option<(DVec2, bool)>,
6767
/// Restore the selection before box selection if it is aborted
68-
selection_before_pointer_down: Vec<NodeId>,
68+
pub selection_before_pointer_down: Vec<NodeId>,
6969
/// If the grip icon is held during a drag, then shift without pushing other nodes
7070
shift_without_push: bool,
7171
disconnecting: Option<InputConnector>,
@@ -74,7 +74,7 @@ pub struct NodeGraphMessageHandler {
7474
select_if_not_dragged: Option<NodeId>,
7575
/// The start of the dragged line (cannot be moved), stored in node graph coordinates
7676
pub wire_in_progress_from_connector: Option<DVec2>,
77-
wire_in_progress_type: FrontendGraphDataType,
77+
pub wire_in_progress_type: FrontendGraphDataType,
7878
/// The end point of the dragged line (cannot be moved), stored in node graph coordinates
7979
pub wire_in_progress_to_connector: Option<DVec2>,
8080
/// State for the context menu popups.

0 commit comments

Comments
 (0)