diff --git a/crates/ui-egui/src/input/shortcuts.rs b/crates/ui-egui/src/input/shortcuts.rs index d128347dfa3..7ce3fb85f5e 100644 --- a/crates/ui-egui/src/input/shortcuts.rs +++ b/crates/ui-egui/src/input/shortcuts.rs @@ -913,6 +913,26 @@ fn handle_escape_and_view_keys(app: &mut PhotocraftApp, ctx: &egui::Context) { } return; } + // Delete Anchor Point (#12773): Esc first clears anchors selected on the saved path targeted in + // the Paths panel, then deselects that path, so clicks edit nothing. Not while its name is typed + // in the panel: egui has already dropped the field's focus, and the panel cancels on Esc. + if !esc_taken + && app.ui.tool == Tool::DeleteAnchorPoint + && !crate::vector_ui::path_renaming(app, ctx) + && let Some((index, _)) = crate::vector_ui::selected_saved_path_index(app) + { + let ds = &app.ui.direct_selection; + let selected = ds.target == Some(crate::direct_select::PathRef::Saved(index)) && (!ds.anchors.is_empty() || ds.segment.is_some()); + if pressed(Key::Escape) { + if selected { + app.ui.direct_selection.anchors.clear(); + app.ui.direct_selection.segment = None; + } else { + app.ui.selected_path = None; + } + return; + } + } // + / − pick a Path Operation with the Pen tools and Path Selection (`path_components`)… crate::path_components::handle_keys(app, ctx); // … and otherwise ⇧+ / ⇧− step the blend mode and ⇧⌥ letters pick one (`blend_keys`). Before the diff --git a/crates/ui-egui/src/tools/vector_ui.rs b/crates/ui-egui/src/tools/vector_ui.rs index 24e1fce37f9..87e8888e984 100644 --- a/crates/ui-egui/src/tools/vector_ui.rs +++ b/crates/ui-egui/src/tools/vector_ui.rs @@ -50,6 +50,7 @@ pub(crate) use path_ops::{ }; #[cfg(test)] use paths_panel::path_context_actions; +pub(crate) use paths_panel::path_renaming; pub use paths_panel::{PathEntry, PathRow, path_rows, paths_footer, paths_panel}; #[cfg(test)] pub(crate) use pen::over_first_anchor; diff --git a/crates/ui-egui/src/tools/vector_ui/paths_panel.rs b/crates/ui-egui/src/tools/vector_ui/paths_panel.rs index 1d02f3fdd7a..a701e76941e 100644 --- a/crates/ui-egui/src/tools/vector_ui/paths_panel.rs +++ b/crates/ui-egui/src/tools/vector_ui/paths_panel.rs @@ -111,6 +111,11 @@ fn rename_id(doc: &Document) -> egui::Id { egui::Id::unique(("path-rename", doc.id.0)) } +/// Is a path's name being typed in the active document's Paths panel? Esc belongs to its field. +pub(crate) fn path_renaming(app: &PhotocraftApp, ctx: &egui::Context) -> bool { + app.session.active().is_some_and(|st| ctx.data(|d| d.get_temp::(rename_id(&st.doc)).is_some())) +} + /// Commands offered by a Paths row's context menu. The row's path is passed explicitly so a /// right-click acts on that row even when another path is selected in the panel. `layer` is the /// layer a `PathRow::Layer` row belongs to (the active layer).