diff --git a/crates/ui-egui/src/dialogs/marks_ui.rs b/crates/ui-egui/src/dialogs/marks_ui.rs index a3987d6073..8e2af52a51 100644 --- a/crates/ui-egui/src/dialogs/marks_ui.rs +++ b/crates/ui-egui/src/dialogs/marks_ui.rs @@ -525,25 +525,36 @@ fn boxes_row() -> Param { let companions: Vec = (0..6).map(|k| format!("hf.text.{k}")).chain(["hf.focused".to_string()]).collect(); Param::custom("hf.boxes", tl!("Header and footer text"), |ui, fields, _cx| { let mut out: Option = None; - for (k, name) in BOX_NAMES.iter().enumerate() { - let key = format!("hf.text.{k}"); - let before = fields.text(&key).unwrap_or_default().to_owned(); - let mut text = before.clone(); - let r = ui - .push_id(("hf-box", k), |ui| TextField::new(tl!(name), craft::ui::contract::Bind::bound(&mut text)).lines(2).show(ui).response) - .inner; - // The field's focus stop is the component: egui's focus sits on its text part. - if craft::ui::runtime::focus::is_focused(ui.ctx(), r.id) { - fields.set("hf.focused", FieldValue::Int(k as i64)); + // Two rows of three, the header's boxes over the footer's, as production lays them out: one row of six runs + // past the dialog's edge. + ui.vertical(|ui| { + for (row, names) in BOX_NAMES.chunks(3).enumerate() { + ui.horizontal(|ui| { + for (col, name) in names.iter().enumerate() { + let k = row * 3 + col; + let key = format!("hf.text.{k}"); + let before = fields.text(&key).unwrap_or_default().to_owned(); + let mut text = before.clone(); + let r = ui + .push_id(("hf-box", k), |ui| { + TextField::new(tl!(name), craft::ui::contract::Bind::bound(&mut text)).lines(2).show(ui).response + }) + .inner; + // The field's focus stop is the component: egui's focus sits on its text part. + if craft::ui::runtime::focus::is_focused(ui.ctx(), r.id) { + fields.set("hf.focused", FieldValue::Int(k as i64)); + } + if text != before { + fields.set(key, FieldValue::Text(text)); + } + out = Some(match out.take() { + Some(o) => o.union(r), + None => r, + }); + } + }); } - if text != before { - fields.set(key, FieldValue::Text(text)); - } - out = Some(match out { - Some(o) => o.union(r), - None => r, - }); - } + }); out.unwrap_or_else(|| ui.response()) }) .companions(companions) diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index d734770ca2..673db11b69 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -271,9 +271,10 @@ pub(crate) fn gated(app: &PdfCraftApp) -> bool { } /// Whether a text field has the keyboard: the one signal behind the Edit rows' state and the native -/// menu's gate. +/// menu's gate. A text field only, as production's `text_edit_focused`: egui's keyboard focus alone is +/// also on an open menu's rows or a button, which would hand Edit ▸ Copy and Paste to them. pub(crate) fn text_editing(ctx: &egui::Context) -> bool { - ctx.egui_wants_keyboard_input() + craft::ui::runtime::windows::WindowHost::of(ctx).typing() } impl PdfCraftApp { diff --git a/crates/ui-egui/tests/it/editing.rs b/crates/ui-egui/tests/it/editing.rs index e23265dff2..c04b85c546 100644 --- a/crates/ui-egui/tests/it/editing.rs +++ b/crates/ui-egui/tests/it/editing.rs @@ -10438,7 +10438,7 @@ fn format_panel_shows_selection_size_and_updates_after_font_applied() { // Apply Times to the whole block font_node.click(); h.run_steps(2); - h.get_by_label("Times").click(); + h.query_all_by_label("Times").next().expect("the Times row").click(); h.run_steps(4); // Now all text is Times, so font combo box updates to Times