Escape keeps the anchor selection under Direct, Convert and Curvature

The overlay no longer clears the selection on Escape; the key goes on to the window as in 0.23.1.
This commit is contained in:
aiongg
2026-11-21 01:55:29 +00:00
parent a32fe7d6fd
commit af50339b27
3 changed files with 20 additions and 6 deletions
+1 -4
View File
@@ -398,7 +398,7 @@ struct Scene {
/// the selected anchors or the picked handle (⌥ alone); Delete and Backspace report
/// [`delete`](BezierOutput::delete) under the tools that delete anchors (Direct, Convert, Curvature, Add Anchor,
/// Delete Anchor), Insert [`insert`](BezierOutput::insert) halfway along the segment leaving the picked anchor;
/// Escape deselects.
/// Escape leaves the selection and goes to the window.
/// - The anchor tools ([`BezierTool::AddAnchor`], [`BezierTool::DeleteAnchor`], [`BezierTool::AutoAddDelete`]) and
/// [`BezierTool::Curvature`] take only a press that hits what they edit, and draw the [`HitMark`] of what a press
/// would take under the pointer. [`segment_mark`](Self::segment_mark), [`anchors`](Self::anchors) and
@@ -1121,9 +1121,6 @@ impl<'a> BezierOverlay<'a> {
self.report.delete = Some(AnchorDelete::new(path, self.selection.anchors.clone(), true));
}
}
if keyed && cx.gesture().is_none() && cx.intents().take(Intent::Cancel) && *self.selection != PathSelection::default() {
self.report.select = Some(PathSelection::default());
}
}
/// The path ⌘A selects: the selection's, else the picked part's, else the only one.
+1 -1
View File
@@ -57,7 +57,7 @@ impl BezierTool {
matches!(self, BezierTool::AddAnchor | BezierTool::DeleteAnchor | BezierTool::AutoAddDelete)
}
/// Whether the tool has the arrow, ⌘A and Esc keys: Direct, Convert and Curvature. Add and Delete have Delete
/// Whether the tool has the arrow and ⌘A keys: Direct, Convert and Curvature. Add and Delete have Delete
/// only, Auto Add/Delete none.
pub(super) fn keyed(self) -> bool {
matches!(self, BezierTool::Direct | BezierTool::Convert | BezierTool::Curvature)
+18 -1
View File
@@ -421,7 +421,7 @@ fn hit_test_matches_the_overlays_press_priority() {
// ---- the anchor tools and the Curvature tool ----
// Arrows, select all and Escape belong to Direct, Convert and Curvature; Add, Delete and Auto Add/Delete have none.
// Arrows and select all belong to Direct, Convert and Curvature; Add, Delete and Auto Add/Delete have none.
#[trial]
fn cmd_or_ctrl_with_page_down_on_a_focused_anchor_scrolls_the_canvas_and_picks_no_part() {
@@ -1202,6 +1202,23 @@ fn arrow_keys_nudge_the_selected_anchors_and_shift_nudges_farther() {
assert_eq!(h.state.borrow().changes.len(), 2, "one edit per press");
}
// Escape on a focused anchor leaves the anchor selection and the targeted path under Direct, Convert and Curvature; it
// goes on to the window. A key still reaches the overlay afterwards.
#[trial]
fn escape_on_a_focused_anchor_keeps_the_selection() {
for tool in [BezierTool::Direct, BezierTool::Convert, BezierTool::Curvature] {
let mut h = two_paths();
h.update(|st| (st.tool, st.selection) = (tool, sel(1, &[(0, 1)])));
h.fixture.key(egui::Key::Tab, egui::Modifiers::NONE).key(egui::Key::Tab, egui::Modifiers::NONE).settle();
let before = h.state.borrow().selection.clone();
assert!(before != PathSelection::default(), "{tool:?}: an anchor is selected");
h.fixture.key(egui::Key::Escape, egui::Modifiers::NONE).settle();
assert_eq!(h.state.borrow().selection, before, "{tool:?}: Escape keeps the selection");
h.fixture.key(egui::Key::ArrowRight, egui::Modifiers::NONE).settle();
assert!(h.last_change().is_some(), "{tool:?}: the overlay still has the keys");
}
}
// A press belongs to the tool it began under: switching the host's tool in the middle of a drag leaves the drag its
// own, and it commits as that tool's edit.
#[trial]