From 0067879a584f8e3c17c4473124038a6c7ef31d33 Mon Sep 17 00:00:00 2001 From: PiMinusMax <121135695+PiMinusMax@users.noreply.github.com> Date: Sat, 10 Oct 2026 17:14:09 +0200 Subject: [PATCH] KEY-ESC: Esc leaves the crop tool before leaving Detail, and a text field's Esc stays its own view.back (Esc) closed dialogs, the keyword painter, full screen and an armed on-image tool, but not the crop tool (a right panel, not app.ui.tool), so Esc with the crop tool open went straight to the grid. It now closes the crop tool like C does (the crop stays); the next Esc goes back to the grid. Esc that ends an edit in a text field (the crop tool's Angle field) also ran Back: egui drops the field's focus as Esc arrives, before shortcuts::handle checks egui_wants_keyboard_input(). The app now records whether a text field had the keyboard at the end of the last frame (LightcraftApp::text_focus); that Esc is then left to the field, like one that closes a popup. New headless tests in tests_crop_tool.rs; both fail without the fix (the existing escape_in_the_angle_field_keeps_the_angle fails with only the crop step). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/lib.rs | 7 +++ crates/ui-egui/src/menus.rs | 3 ++ crates/ui-egui/src/shortcuts.rs | 2 + crates/ui-egui/src/tests_crop_tool.rs | 64 +++++++++++++++++++++++++++ docs/parity-checklist.md | 2 +- 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/src/tests_crop_tool.rs diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 6b5033e0c..c3e2a4ca4 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -43,6 +43,8 @@ mod tests_album_picker; #[cfg(test)] mod tests_crop_rotate; #[cfg(test)] +mod tests_crop_tool; +#[cfg(test)] mod tests_curve; #[cfg(test)] mod tests_date_picker; @@ -229,6 +231,9 @@ pub struct LightcraftApp { /// The keyboard shortcuts editor is waiting for a key press for this command: no shortcut /// fires (the native menu bar drops its accelerators too) until it gets one or is cancelled. pub recording_shortcut: Option, + /// A text field had the keyboard at the end of the last frame. egui drops the focus as Esc + /// arrives, before the shortcuts are read, so this is how Esc there stays the field's own. + pub text_focus: bool, /// The host is [`headless::Headless`] (it answers viewport screenshot commands itself). pub headless_host: bool, /// Warnings to show one at a time (damaged settings files…, issue #103). @@ -341,6 +346,7 @@ impl LightcraftApp { native_menu: false, native_shortcuts: Default::default(), recording_shortcut: None, + text_focus: false, headless_host: false, notices: vec![], quit_prompt: None, @@ -1074,6 +1080,7 @@ impl LightcraftApp { panels::keyword_list::drag_feedback(self, &ctx); panels::toast(self, &ctx); self.widgets = widgets::take_registry(&ctx); + self.text_focus = ctx.egui_wants_keyboard_input(); self.end_frame(&ctx, t0); } } diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index aff0326a4..9ed3197e6 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -401,6 +401,9 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option