Repository navigation
Mac: ⌘C, ⌘V, ⌘X, ⌘A and ⌘Z work in the window's text fields (#340) - #352
sundarshahi wants to merge 2 commits into
Conversation
Port the remaining public page-handler change after Asagiri's native Edit menu and translated menu labels were already integrated. Leave Mac copy to the native menu while retaining Ctrl-C handling on Windows and Linux and the terminal and text fields' own editing behavior. The original page failed the new Mac duplicate-copy regression. All nine headless clipboard cases across the three platforms and packaged page assembly now pass. Native AppKit key dispatch remains a separate runtime qualification. Upstream-PR: libracoder/kiri#352 Upstream-Commit: d629da8bc64a85833feae3ae7e2c4e0d3f759fe7 Co-authored-by: Andre Kurait <akurait@amazon.com> Signed-off-by: Andre Kurait <akurait@amazon.com>
|
I see copy/paste does not work in container terminal as well, will this be fixing that as well? @sundarshahi |
|
Yes, on the Mac. A container's Terminal tab types commands into an ordinary text field, so it had the same cause: with no Edit menu, ⌘V, ⌘X, ⌘C and ⌘A in that field did nothing. With this PR they work there too. I checked it on that tab's own field, pressing the keys through the app the way a keyboard does, on main and on this branch, 3 runs each: The terminal panel at the bottom of the window, the one with tabs and splits, handles ⌘C and ⌘V itself. Both already work there on main, and this PR doesn't change it. If you still see it with this PR, could you say which system you're on and which of the two terminals it was? This PR only changes the Mac. On Windows and Linux, the WebView already handles Ctrl+C and Ctrl+V in text fields itself. |
…er#340) On the Mac, the editing keys reach a WKWebView's text fields through a menu item's key equivalent. The menu bar had no Edit menu, so every one of those keys beeped in Settings' fields. An Edit menu with the standard items (undo:, redo:, cut:, copy:, paste:, selectAll:) sends them down the responder chain to the page. The page still sees each key first. Keys it handles itself (the terminal's ⌘C and ⌘V, a list's ⌘A) are cancelled there and never reach the menu. The page's own ⌘C for selected log text was there only because the Edit menu was missing. On the Mac, Edit → Copy now does that job, so the page no longer copies the text a second time. Windows and Linux are unchanged, and the log-selection test runs on all three.
d629da8 to
ca07e27
Compare
|
@sundarshahi one addition before this goes in, please. The page sets |
The window sets user-select: none on body, and .gfind input didn't turn it back on. Credit to @eryajf, who spotted it in libracoder#397.
|
Done in 0394b09:
|
What this changes and why
On the Mac, ⌘C, ⌘V, ⌘X, ⌘A and ⌘Z do nothing in the window's text fields (Settings → proxy, registry logins, env editors) and the Mac beeps. AppKit gives these keys to a WKWebView through the menu bar's Edit menu, and Kiri's menu bar has only the app menu and View. This adds the standard Edit menu.
Fixes #340
Problem
main_menu(crates/kiri/src/ui/mac.rs:261) builds the app menu and View only.paste:down the responder chain to the focused field, and the Mac beeps.index.htmlalready says so ("The window has no Edit menu, which is where the Mac gets Copy's key from"). That's why Logs: select and copy the text #177 added a page handler for ⌘C on selected log text. Text fields were left without one.Fix
undo:redo:cut:copy:paste:selectAll:). It's rebuilt with the rest of the menu bar when the language changes (relang).htKeycallspreventDefault);tests/ui/logselect.jsnow runs as all three systems:On Windows and Linux, WebView2 and WebKitGTK handle Ctrl+C and Ctrl+V in text fields themselves, so nothing changes there. I didn't test those two systems by hand, so I kept the page's Ctrl+C handler there as it was. If you'd rather remove it everywhere, happy to.
How you tested it
macOS 27 (Apple silicon),
cargo build -p kiri,target/debug/kiri ui.The keys were pressed from inside the app, through the same path a keyboard uses. A temporary harness (not in this PR) built real
NSEventkey-downs with ⌘ (⇧⌘ for redo) and passed them toNSApp.sendEvent:, aimed at a focused<input>in the page. It then read the field's value back. The clipboard was set toPASTE-OKfirst. The same harness ran on main'smac.rsand on this branch, 3 times each:How to read it:
A second check selected a non-editable log line and pressed ⌘C. Pasting into the field gave
LOG-LINE, so selected text still copies through the menu now that the page doesn't.python3 scripts/ui-test.py: all pass, including the parity runs.logselect.jsfails against main'sindex.htmlon macOS only (copies sent: got 1 want 0).python3 scripts/i18n-check.py:PASS 1671 keys, 37 language file(s), 0 problem(s).cargo test -p kiri --bin kiri lang::passes.cargo clippy -p kiriadds no warnings in the changed lines.Tested on: macOS 27.0 (Apple silicon). Windows and Linux: page tests only, as above.
How you found it
AI tools used to write this change: yes. An AI coding assistant helped write and test it, including the translations. I reviewed and tested every change.
Checklist
cargo fmt,cargo clippyand the tests pass