fix(shortcuts): honor Cmd as the accelerator modifier on macOS (#202) (#206)

Keyboard accelerators (copy/paste/save/undo/new/open) were gated on
`Modifiers::control()`, which on macOS matches only the physical Control
key. Mac users pressing Cmd+C/V/S/Z got nothing, contrary to platform
convention and every other Mac app.

Switch the gate to `Modifiers::command()`, which iced resolves to the
Logo (Cmd) key on macOS and Ctrl on Windows/Linux. On non-mac targets
this expands to exactly `control()`, so behavior there is unchanged.

Also make the Keyboard Shortcuts reference window display the
platform-correct modifier name (Cmd vs Ctrl) so the help matches the
keys the user actually presses.

Closes #202

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kevin GriffinandClaude Opus 4.8 authored and GitHub committed 2026-06-27 19:33:08 +03:00
1 parent ddf576765b
commit 73eabc3aaa
2 files changed
+36 -17

No files matched your search

+7 -3
View File
@@ -1449,7 +1449,11 @@ impl OpenCADStudio {
text,
..
}) => {
let ctrl = modifiers.control();
// Platform-aware accelerator modifier: Cmd on macOS,
// Ctrl on Windows/Linux. Using `command()` rather than
// `control()` makes Cmd+C/V/S/Z etc. work on Mac, per
// the platform's keyboard conventions.
let accel = modifiers.command();
let shift = modifiers.shift();
// Any key that produces a printable glyph types it,
// even when its logical key resolves to navigation
@@ -1459,7 +1463,7 @@ impl OpenCADStudio {
// those numpad digits aren't swallowed as history
// navigation. Whitespace / control text (Space,
// Enter, Tab) falls through to the named handlers.
if !ctrl && status == Status::Ignored {
if !accel && status == Status::Ignored {
if let Some(t) = text.as_deref() {
if !t.is_empty()
&& t.chars().all(|c| !c.is_control() && !c.is_whitespace())
@@ -1543,7 +1547,7 @@ impl OpenCADStudio {
keyboard::Key::Named(keyboard::key::Named::F12) => {
Some(Message::ToggleDynInput)
}
keyboard::Key::Character(c) if ctrl => match c.as_str() {
keyboard::Key::Character(c) if accel => match c.as_str() {
"n" => Some(Message::TabNew),
"o" => Some(Message::OpenFile),
"s" if !shift => Some(Message::SaveFile),