#3172: the Paste button's name has no macOS key on Windows and Linux

Home › Paste is named "Paste" for screen readers. Its hint adds the key as the platform writes it, so the name no longer carries macOS's ⌘V on Windows and Linux. The status bar's Go To hint uses the platform's key too. A menu button's KeyTip is looked up from the English tip, so it still appears in other interface languages.

See the pull request for the discussion.
This commit is contained in:
squalorso
2026-11-18 19:32:22 +07:00
committed by GitHub
parent 3ab2e53a89
commit 4e8c9d5531
8 changed files with 70 additions and 8 deletions
+4 -1
View File
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -775,8 +775,11 @@ pub fn status_bar(app: &mut WordApp, ui: &mut Ui) {
resp
};
let st = |ui: &mut Ui, s: &str| st_icon(ui, None, s);
// Go To's key as this platform writes it ("Go To (Ctrl+Alt+G)", "Go To (⌘⌥G)" on macOS).
let goto_key = crate::widgets::shortcut_text(app, "edit.goto");
let goto_hint = if goto_key.is_empty() { tl!("Go To").to_string() } else { format!("{} ({goto_key})", tl!("Go To")) };
if st(ui, &crate::i18n::fmt(tl!("Page {page} of {pages}"), &[("page", &page.to_string()), ("pages", &l.pages.len().to_string())]))
.on_hover_text(tl!("Go To (⌘⌥G)"))
.on_hover_text(goto_hint)
.clicked()
{
let _ = app.run("ui.dialog", json!({"name": "goto"}));
+29
View File
@@ -550,6 +550,35 @@ fn qat_digit_runs_once_and_never_types_into_the_document() {
}
}
/// Home's Paste, a menu button, shows its keytip whatever the interface language. The keytips
/// table holds the English tips, and `menu_button` matched it with its translated one, which no
/// other language's "Paste" equals or begins with. Pseudo-localization stands in for one.
#[test]
fn a_menu_buttons_keytip_does_not_depend_on_the_language() {
let a = app();
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
h.run_steps(3);
crate::i18n::pseudo::set(true);
let key = |key| egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE };
h.input_mut().events.push(key(egui::Key::F10));
h.step();
h.input_mut().events.extend([key(egui::Key::H), egui::Event::Text("h".into())]);
h.run_steps(3);
let rects = h.ctx.data(|d| d.get_temp::<Vec<(egui::Rect, String)>>(rects_id())).unwrap_or_default();
crate::i18n::pseudo::set(false);
assert_eq!((h.state().ui.tab.as_str(), h.state().ui.keytips), ("Home", Phase::Commands));
let paste = controls_public("Home").iter().position(|c| c.id == "edit.paste").unwrap();
let letter = h.ctx.data(|d| d.get_temp::<Vec<String>>(letters_id().with("Home"))).and_then(|l| l.get(paste).cloned()).unwrap();
assert!(rects.iter().any(|(_, l)| *l == letter), "Paste's {letter} badge is drawn: {rects:?}");
}
/// #1697 review: Alt, V, U through the whole app (the canvas has the keyboard), not only
/// `handle_key`: Full Screen View turns on and neither letter types into the document.
#[test]
+2 -1
View File
@@ -47,7 +47,8 @@ pub(super) fn home(app: &mut WordApp, ui: &mut Ui) {
let st = app.session.run("format.state", &json!({})).unwrap_or_default();
let flag = |k: &str| st.get(k).and_then(Value::as_bool).unwrap_or(false);
group(ui, "Clipboard", Some("edit.clipboardPane"), app, |ui, app| {
menu_button(ui, app, crate::widgets::MenuButtonOptions::new("paste", Some("Paste"), "Paste (⌘V)", true, "edit.paste"), |ui, app| {
// The hint adds the platform's key ("Paste (Ctrl+V)"); the name screen readers read is "Paste".
menu_button(ui, app, crate::widgets::MenuButtonOptions::new("paste", Some("Paste"), "Paste", true, "edit.paste"), |ui, app| {
mi(ui, app, "Paste", "edit.paste", json!({}));
mi(ui, app, "Keep Text Only", "edit.pasteText", json!({}));
mi(ui, app, "Merge Formatting", "edit.pasteMerge", json!({}));
+21
View File
@@ -3618,6 +3618,27 @@ fn the_ribbon_boxes_name_themselves_for_a_screen_reader() {
}
}
/// The Paste button is named "Paste": its hint adds the key as the platform writes it, so its
/// name no longer carries macOS's "⌘V", which screen readers read on Windows as "Paste (⌘V)".
#[test]
fn the_paste_button_is_named_without_a_mac_key() {
use egui::accesskit::Role;
use egui_kittest::kittest::Queryable;
let mut a = app();
a.run("file.new", json!({"template": "sample"})).unwrap();
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
h.run_steps(6);
assert!(h.query_by_role_and_label(Role::Button, "Paste").is_some(), "the Paste button is called \"Paste\"");
assert!(h.query_by_role_and_label(Role::Button, "Paste (⌘V)").is_none(), "no Mac key in its name");
}
/// #1015: focusing Save is not enough: its dialog must expose the question and any failed
/// save's explanation, so assistive technology has context for the three choices.
#[test]
+5 -2
View File
@@ -292,6 +292,9 @@ impl<'a> MenuButtonOptions<'a> {
pub fn menu_button(ui: &mut Ui, app: &mut WordApp, options: MenuButtonOptions<'_>, menu: impl FnOnce(&mut Ui, &mut WordApp)) {
let MenuButtonOptions { icon, label, tip, big_btn, id } = options;
// The keytips table holds the tips in English, so the badge looks this one up, not the
// translated tip, which no other language's "Paste" equals.
let keytip_name = tip;
let (label, tip) = (label.map(|l| tl!(l)), tl!(tip));
let label = label.filter(|_| big_btn || !crate::ribbon_fit::compact(ui.ctx()));
let t = Tokens::get(ui.ctx());
@@ -307,7 +310,7 @@ pub fn menu_button(ui: &mut Ui, app: &mut WordApp, options: MenuButtonOptions<'_
.fold(0.0, f32::max);
let w = (galley_w + 22.0).max(44.0);
let (r, resp) = ui.allocate_exact_size(vec2(w, CONTENT_H), Sense::click());
keytip_badge(ui, r, "menu", tip);
keytip_badge(ui, r, "menu", keytip_name);
bg_if(ui, r, &resp, false, &t, on);
icons::paint(ui.painter(), Rect::from_center_size(pos2(r.center().x, r.min.y + BIG_ICON_Y), vec2(32.0, 32.0)), icon, c, a);
let lines: Vec<&str> = label.unwrap_or("").split('\n').collect();
@@ -320,7 +323,7 @@ pub fn menu_button(ui: &mut Ui, app: &mut WordApp, options: MenuButtonOptions<'_
} else {
let text_w = label.map(|l| ui.ctx().fonts_mut(|f| f.layout_no_wrap(l.to_string(), regular(11.5), t.text).size().x) + 6.0).unwrap_or(0.0);
let (r, resp) = ui.allocate_exact_size(vec2(24.0 + text_w + 10.0, 22.0), Sense::click());
keytip_badge(ui, r, "menu", tip);
keytip_badge(ui, r, "menu", keytip_name);
bg_if(ui, r, &resp, false, &t, on);
let rtl = crate::rtl::flows(ui);
let lead = |inset: f32| crate::rtl::lead_x(rtl, r, inset);
+3 -2
View File
File diff suppressed because one or more lines are too long
+2 -1
View File
File diff suppressed because one or more lines are too long