From 1b0a9dae1b33dc40a0d7491a28274bc3680c698a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 24 Oct 2026 15:49:45 -0700 Subject: [PATCH] LR-META-INFO: the Info panel's GPS field is a TextField, so Esc gives an edit up The GPS box was an egui TextEdit: Esc left the field with the typed text kept, and leaving the field saved it. It is now the app's TextField, as the other Info fields are: Esc puts the text back and saves nothing, and the field gets the Cut / Copy / Paste / Select All menu. --- crates/ui-egui/src/headless.rs | 11 +++++++++++ crates/ui-egui/src/panels/right.rs | 9 ++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/headless.rs b/crates/ui-egui/src/headless.rs index b7343b169..296a1247b 100644 --- a/crates/ui-egui/src/headless.rs +++ b/crates/ui-egui/src/headless.rs @@ -3117,6 +3117,17 @@ mod tests { h.settle(SETTLE); let gps: Vec = (0..4).map(|i| meta(&h, i).gps.is_some()).collect(); assert_eq!(gps, [true, true, false, false]); + // Esc gives a GPS edit up + exec(&mut h, "library.select", json!({"ids": [ids[0], ids[1]], "active": ids[0]})); + h.settle(SETTLE); + let before = meta(&h, 0).gps; + ask(&mut h, "ui.clickWidget", json!({"id": "field:gps"})); + ask(&mut h, "ui.key", json!({"key": "End"})); + ask(&mut h, "ui.text", json!({"text": "5"})); + ask(&mut h, "ui.key", json!({"key": "Escape"})); + ask(&mut h, "ui.key", json!({"key": "Tab"})); + h.settle(SETTLE); + assert_eq!((meta(&h, 0).gps, meta(&h, 1).gps), (before, before)); } /// Local: a folder's photos show without joining the library; the breadcrumb, Include diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rs index 6da043831..1afad9bc3 100644 --- a/crates/ui-egui/src/panels/right.rs +++ b/crates/ui-egui/src/panels/right.rs @@ -758,17 +758,16 @@ fn info(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) { ui.label(egui::RichText::new("GPS").size(11.5).color(t.text_dim)); let mut edit: FieldEdit = ui.data(|d| d.get_temp(gid)).unwrap_or_else(|| FieldEdit::new(&gps, gps_mixed, &selected)); let hint = crate::i18n::tr(if gps_mixed { MIXED } else { "latitude, longitude" }); - let r = ui.add(egui::TextEdit::singleline(&mut edit.text).hint_text(hint).desired_width(f32::INFINITY)); - crate::widgets::screen_reader_name(ui.ctx(), r.id, "GPS"); - register(ui.ctx(), "field:gps", r.rect); + let r = crate::text_field::TextField::singleline("field:gps", &mut edit.text).hint(hint).label("GPS").width(f32::INFINITY).show(ui); edit.typed |= edit.text != edit.start; - if r.has_focus() { + if r.editing { ui.data_mut(|d| d.insert_temp(gid, edit.clone())); } else { ui.data_mut(|d| d.remove::(gid)); } + // Return or leaving saves; Esc gives the edit up let text = edit.text.trim(); - if r.lost_focus() + if r.committed() && (text != edit.start || edit.clears()) && let Err(e) = app.run("photo.setMeta", json!({"ids": edit.ids, "gps": text})) {