From 1b99cebb156cffc24d1e599c3275ad46ad045ca3 Mon Sep 17 00:00:00 2001 From: andeecollard Date: Mon, 19 Oct 2026 17:37:24 +0100 Subject: [PATCH 1/8] Keep macOS Settings, Hide and Minimize shortcuts available --- crates/engine/src/commands.rs | 2 +- crates/engine/src/extra_cmds.rs | 2 +- crates/engine/src/prefs.rs | 2 +- crates/engine/src/shell_commands.rs | 8 +++- crates/ui-egui/src/kys_import_tests.rs | 6 ++- crates/ui-egui/src/layer_shortcut_tests.rs | 7 ++-- crates/ui-egui/src/menu_catalog.rs | 6 +-- crates/ui-egui/src/native_menu.rs | 40 +++++++++++++++--- crates/ui-egui/src/shortcut_dispatch/tests.rs | 4 +- crates/ui-egui/src/shortcuts.rs | 2 + docs/macos-shortcuts.md | 42 +++++++++++++++++++ 11 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 docs/macos-shortcuts.md diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index 9b4d4a7472..80cd47261f 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -1390,7 +1390,7 @@ fn build() -> Vec { menu: &["Image", "Adjustments"], shortcut: match kind { "levels" => Some("Cmd+L"), - "curves" => Some("Cmd+M"), + "curves" => Some(crate::shell_commands::CURVES_SHORTCUT), "hueSaturation" => Some("Cmd+U"), "colorBalance" => Some("Cmd+B"), "invert" => Some("Cmd+I"), diff --git a/crates/engine/src/extra_cmds.rs b/crates/engine/src/extra_cmds.rs index 072a3d4417..7a24543c27 100644 --- a/crates/engine/src/extra_cmds.rs +++ b/crates/engine/src/extra_cmds.rs @@ -1032,7 +1032,7 @@ pub fn specs() -> Vec { "layer.hideLayers", "Hide Layers", &["Layer"], - Some("Cmd+,"), + Some(crate::shell_commands::HIDE_LAYERS_SHORTCUT), r##"{"layer":id?} (shows them instead when every targeted layer is already hidden, so ⌘, toggles)"##, has_layer, hide_or_show diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index ed8b7f148f..f3c237f596 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -2584,7 +2584,7 @@ pub fn specs() -> Vec { ), spec!("prefs.reset", "Reset Preferences", [], None, r##"{"path":"section|section.key"?=everything}"##, prefs_reset, false), // Photoshop: ⌘K opens Preferences › General (⌘, is Layer › Hide Layers). - section!("edit.preferences.general", "General…", Some("Cmd+K")), + section!("edit.preferences.general", "General…", Some(crate::shell_commands::SETTINGS_SHORTCUT)), section!("edit.preferences.interface", "Interface…"), section!("edit.preferences.workspace", "Workspace…"), section!("edit.preferences.tools", "Tools…"), diff --git a/crates/engine/src/shell_commands.rs b/crates/engine/src/shell_commands.rs index 2bd765673f..d584b6d105 100644 --- a/crates/engine/src/shell_commands.rs +++ b/crates/engine/src/shell_commands.rs @@ -5,6 +5,12 @@ //! list, conflicts, `.kys` import and export all work without the UI (the UI is a layer on //! top). The app's tests keep these tables equal to its own. +/// Mac defaults leave system actions on their usual Command shortcuts. +pub const SETTINGS_SHORTCUT: &str = if cfg!(target_os = "macos") { "Cmd+," } else { "Cmd+K" }; +pub const EXTRAS_SHORTCUT: &str = if cfg!(target_os = "macos") { "Ctrl+Cmd+H" } else { "Cmd+H" }; +pub const CURVES_SHORTCUT: &str = if cfg!(target_os = "macos") { "Ctrl+Cmd+M" } else { "Cmd+M" }; +pub const HIDE_LAYERS_SHORTCUT: &str = if cfg!(target_os = "macos") { "Ctrl+Cmd+," } else { "Cmd+," }; + /// Shell commands: id, label, menu path, default shortcut. pub const SHELL_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[ ("ui.symmetryTransform", "Transform Symmetry", &[], None), @@ -36,7 +42,7 @@ pub const SHELL_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[ ("view.show.guides", "Guides", &["View", "Show"], Some("Cmd+;")), ("view.snap", "Snap", &["View"], Some("Cmd+Shift+;")), ("view.lockGuides", "Lock Guides", &["View"], Some("Cmd+Alt+;")), - ("view.extras", "Extras", &["View"], Some("Cmd+H")), + ("view.extras", "Extras", &["View"], Some(EXTRAS_SHORTCUT)), ("view.show.targetPath", "Target Path", &["View", "Show"], Some("Cmd+Shift+H")), ("view.screenMode.cycle", "Cycle Screen Mode", &[], Some("F")), // Photoshop's interface brightness shortcuts: step through the four Pro themes. diff --git a/crates/ui-egui/src/kys_import_tests.rs b/crates/ui-egui/src/kys_import_tests.rs index b31ee98e68..54c8d21c26 100644 --- a/crates/ui-egui/src/kys_import_tests.rs +++ b/crates/ui-egui/src/kys_import_tests.rs @@ -142,7 +142,11 @@ fn import_button_fills_the_dialog_and_ok_applies_the_set() { assert_eq!(h.state().ui.status, "", "the import failed"); let overrides = field(&h, "overrides"); assert_eq!(overrides["filter.blur.gaussianBlur"], json!("Cmd+Ctrl+Alt+G")); - assert!(overrides.get("edit.preferences.general").is_none(), "Cmd+K is Preferences' default: {overrides}"); + if cfg!(target_os = "macos") { + assert_eq!(overrides["edit.preferences.general"], json!("Cmd+K"), "an imported legacy binding stays explicit on Mac"); + } else { + assert!(overrides.get("edit.preferences.general").is_none(), "Cmd+K is Preferences' default: {overrides}"); + } assert_eq!(overrides["filter.lastFilter"], json!("Cmd+F")); assert!(overrides.get("edit.undo").is_none(), "Cmd+Z is the default again: {overrides}"); assert!(overrides.get("select.all").is_none(), "already the default: {overrides}"); diff --git a/crates/ui-egui/src/layer_shortcut_tests.rs b/crates/ui-egui/src/layer_shortcut_tests.rs index 96ab2520dc..27209d792c 100644 --- a/crates/ui-egui/src/layer_shortcut_tests.rs +++ b/crates/ui-egui/src/layer_shortcut_tests.rs @@ -30,11 +30,12 @@ fn active(app: &PhotocraftApp) -> &photocraft_doc::Layer { } #[test] -fn command_comma_toggles_the_layers_visibility() { +fn hide_layers_shortcut_toggles_visibility_without_taking_mac_settings() { let mut app = app(); - press(&mut app, Key::Comma, Modifiers::COMMAND); + let mods = if cfg!(target_os = "macos") { Modifiers::COMMAND | Modifiers::CTRL } else { Modifiers::COMMAND }; + press(&mut app, Key::Comma, mods); assert!(!active(&app).visible); - press(&mut app, Key::Comma, Modifiers::COMMAND); + press(&mut app, Key::Comma, mods); assert!(active(&app).visible); } diff --git a/crates/ui-egui/src/menu_catalog.rs b/crates/ui-egui/src/menu_catalog.rs index 1d98028625..a8d6edff61 100644 --- a/crates/ui-egui/src/menu_catalog.rs +++ b/crates/ui-egui/src/menu_catalog.rs @@ -148,7 +148,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[ (&["Edit"], "Menus…", Some("Cmd+Alt+Shift+M"), "edit.menus"), (&["Edit"], "Toolbar…", None, "edit.toolbar"), (&["Edit"], "---", None, "---"), - (&["Edit", "Preferences"], "Settings…", Some("Cmd+K"), "edit.preferences.general"), + (&["Edit", "Preferences"], "Settings…", Some(photocraft_engine::shell_commands::SETTINGS_SHORTCUT), "edit.preferences.general"), (&["Edit", "Preferences"], "AI Integrations…", None, "edit.preferences.integrations"), (&["Edit", "Preferences"], "Interface…", None, "edit.preferences.interface"), (&["Edit", "Preferences"], "Workspace…", None, "edit.preferences.workspace"), @@ -183,7 +183,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[ (&["Image"], "---", None, "---"), (&["Image", "Adjustments"], "Brightness/Contrast…", None, "image.adjustments.brightnessContrast"), (&["Image", "Adjustments"], "Levels…", Some("Cmd+L"), "image.adjustments.levels"), - (&["Image", "Adjustments"], "Curves…", Some("Cmd+M"), "image.adjustments.curves"), + (&["Image", "Adjustments"], "Curves…", Some(photocraft_engine::shell_commands::CURVES_SHORTCUT), "image.adjustments.curves"), (&["Image", "Adjustments"], "Exposure…", None, "image.adjustments.exposure"), (&["Image", "Adjustments"], "Vibrance…", None, "image.adjustments.vibrance"), (&["Image", "Adjustments"], "Hue/Saturation…", Some("Cmd+U"), "image.adjustments.hueSaturation"), @@ -660,7 +660,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[ (&["View", "Screen Mode"], "Full Screen Mode With Menu Bar", None, "view.screenMode.fullScreenWithMenuBar"), (&["View", "Screen Mode"], "Full Screen Mode", None, "view.screenMode.fullScreen"), (&["View"], "---", None, "---"), - (&["View"], "Extras", Some("Cmd+H"), "view.extras"), + (&["View"], "Extras", Some(photocraft_engine::shell_commands::EXTRAS_SHORTCUT), "view.extras"), (&["View", "Show"], "Layer Edges", None, "view.show.layerEdges"), (&["View", "Show"], "Selection Edges", None, "view.show.selectionEdges"), (&["View", "Show"], "Target Path", Some("Cmd+Shift+H"), "view.show.targetPath"), diff --git a/crates/ui-egui/src/native_menu.rs b/crates/ui-egui/src/native_menu.rs index e76c20eecd..b6fb68fd45 100644 --- a/crates/ui-egui/src/native_menu.rs +++ b/crates/ui-egui/src/native_menu.rs @@ -9,8 +9,8 @@ //! use the same app menu; //! - **Window** gets Minimize, Zoom and Bring All to Front, with the open documents after it //! (where a Mac app lists its windows), and **Help** the system search field; -//! - **clashes** with the system's keys (⌘H, ⌘M, ⌘W, ⌘,) are resolved in PhotoCraft's favour, and -//! reported; Hide and Minimize move to ⌃⌘H and ⌃⌘M, as Photoshop does. +//! - Mac defaults leave ⌘H, ⌘M and ⌘, to Hide, Minimize and Settings. Explicit custom +//! bindings are preserved; clashes are reported and system items give way when needed. //! //! **Keys stay with egui.** AppKit runs a menu's key equivalents before the window sees the key, //! which would skip PhotoCraft's key rules (text fields keep ⌘C/⌘V/⌘Z, dialogs and Camera Raw are @@ -835,10 +835,15 @@ mod tests { assert_eq!(titles, ["PhotoCraft", "File", "Edit", "Image", "Layer", "Type", "Select", "Filter", "View", "Window", "Help"]); } - /// PhotoCraft keeps Photoshop's ⌘H, ⌘M, ⌘W and ⌘, (Hide Layers): the system items give way. + /// Explicit saved creative bindings still take priority over the system fallbacks. #[test] fn clashes_are_resolved_in_photocrafts_favour() { - let l = layout(true); + let mut a = app(true); + for (id, sc) in [("view.extras", "Cmd+H"), ("image.adjustments.curves", "Cmd+M"), ("layer.hideLayers", "Cmd+,"), ("edit.preferences.general", "Cmd+K")] + { + a.run("edit.keyboardShortcuts", json!({"set": {id: sc}})).unwrap(); + } + let l = photocraft_layout(&crate::menus::menu_items(&a), Lang::EN, "auto"); let clash = |sc: &str| l.clashes.iter().find(|c| c.shortcut == sc).map(|c| c.command.as_str()); assert_eq!(clash("Cmd+H"), Some("view.extras")); assert_eq!(clash("Cmd+M"), Some("image.adjustments.curves")); @@ -853,6 +858,31 @@ mod tests { assert!(!file.children.contains(&Node::Standard(Standard::CloseWindow)), "⌘W stays File › Close"); } + #[test] + fn platform_defaults_keep_mac_actions_and_creative_actions_separate() { + let a = app(true); + let keys = crate::shortcut_dispatch::bindings(&a); + let binding = |key: &str| keys.iter().find(|(_, sc)| Some(*sc) == crate::shortcuts::parse(key)).map(|(id, _)| id.as_str()); + if cfg!(target_os = "macos") { + assert_eq!(binding("Cmd+,"), Some("edit.preferences.general")); + assert_eq!(binding("Cmd+H"), None); + assert_eq!(binding("Cmd+M"), None); + assert_eq!(binding("Ctrl+Cmd+H"), Some("view.extras")); + assert_eq!(binding("Ctrl+Cmd+M"), Some("image.adjustments.curves")); + assert_eq!(binding("Ctrl+Cmd+,"), Some("layer.hideLayers")); + let l = layout(true); + assert_eq!(l.bar.find(HIDE).unwrap().shortcut.as_deref(), Some("Cmd+H")); + assert!(l.bar.menu(MenuRole::Window).unwrap().children.contains(&Node::Standard(Standard::Minimize))); + assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+,")); + assert!(!l.clashes.iter().any(|c| ["Cmd+H", "Cmd+M", "Cmd+,"].contains(&c.shortcut))); + } else { + assert_eq!(binding("Cmd+K"), Some("edit.preferences.general")); + assert_eq!(binding("Cmd+H"), Some("view.extras")); + assert_eq!(binding("Cmd+M"), Some("image.adjustments.curves")); + assert_eq!(binding("Cmd+,"), Some("layer.hideLayers")); + } + } + /// Themes and the appearance-mode cycle move from Window to the app menu's Appearance. #[test] fn themes_move_to_the_app_menus_appearance() { @@ -916,7 +946,7 @@ mod tests { assert_eq!(sc("edit.undo").as_deref(), Some("Cmd+Z")); assert_eq!(sc("edit.copy").as_deref(), Some("Cmd+C")); assert_eq!(sc("edit.paste").as_deref(), Some("Cmd+V")); - assert_eq!(sc("layer.hideLayers").as_deref(), Some("Cmd+,")); + assert_eq!(sc("layer.hideLayers").as_deref(), Some(photocraft_engine::shell_commands::HIDE_LAYERS_SHORTCUT)); let app = app(true); let bindings = crate::shortcut_dispatch::bindings(&app); for it in crate::menus::menu_items(&app).iter().filter(|it| it.enabled) { diff --git a/crates/ui-egui/src/shortcut_dispatch/tests.rs b/crates/ui-egui/src/shortcut_dispatch/tests.rs index 00f1a120a3..37504f7c1b 100644 --- a/crates/ui-egui/src/shortcut_dispatch/tests.rs +++ b/crates/ui-egui/src/shortcut_dispatch/tests.rs @@ -265,7 +265,9 @@ fn common_shortcuts_work_after_clicking_panels() { assert_ne!(h.state().ui.panels.layers, layers, "{place:?}: F7 toggles Layers"); press(&mut h, "F7"); // Dialogs: Image Size (⌥⌘I, shown in the menu but unbound before #127) and Levels (⌘L). - for (sc, what) in [("Cmd+Alt+I", "Image Size"), ("Cmd+Alt+C", "Canvas Size"), ("Cmd+L", "Levels"), ("Cmd+M", "Curves")] { + for (sc, what) in + [("Cmd+Alt+I", "Image Size"), ("Cmd+Alt+C", "Canvas Size"), ("Cmd+L", "Levels"), (photocraft_engine::shell_commands::CURVES_SHORTCUT, "Curves")] + { press(&mut h, sc); assert_eq!(h.state().ui.dialogs.len(), 1, "{place:?}: {sc} opens {what}"); h.state_mut().ui.dialogs.clear(); diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index 1ad8d6d92a..81a91f8968 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -62,6 +62,7 @@ pub fn pretty(s: &str) -> String { .into_iter() .map(|p| match (p, mac) { ("Cmd", true) => "⌘".to_string(), + ("Ctrl", true) => "⌃".to_string(), ("Cmd", false) => "Ctrl".to_string(), ("Shift", true) => "⇧".to_string(), ("Alt", true) => "⌥".to_string(), @@ -935,6 +936,7 @@ mod tests { let mac = cfg!(target_os = "macos"); assert_eq!(pretty("Cmd+Shift+N"), if mac { "⌘⇧N" } else { "Ctrl+Shift+N" }); // Lone keys and inline-hint combos. + assert_eq!(pretty("Ctrl+Cmd+H"), if mac { "⌃⌘H" } else { "Ctrl+Ctrl+H" }); assert_eq!(pretty("Alt"), if mac { "⌥" } else { "Alt" }); assert_eq!(pretty("Shift+Alt"), if mac { "⇧⌥" } else { "Shift+Alt" }); assert_eq!(pretty("Enter"), if mac { "↩" } else { "Enter" }); diff --git a/docs/macos-shortcuts.md b/docs/macos-shortcuts.md new file mode 100644 index 0000000000..c06dcfc837 --- /dev/null +++ b/docs/macos-shortcuts.md @@ -0,0 +1,42 @@ +# macOS keyboard conventions + +PhotoCraft keeps macOS application actions on their familiar shortcuts. Creative +commands that conflict use a Control–Command variant on macOS. Other platforms +keep their existing defaults. + +| Application action | macOS | +| --- | --- | +| Settings | ⌘, | +| Hide application | ⌘H | +| Hide others | ⌥⌘H | +| Minimize | ⌘M | +| Close document | ⌘W | +| Quit | ⌘Q | + +| Creative action | macOS default | Windows/Linux default | +| --- | --- | --- | +| Extras | ⌃⌘H | Ctrl+H | +| Curves | ⌃⌘M | Ctrl+M | +| Hide Layers | ⌃⌘, | Ctrl+, | + +## Compatibility and customisation + +This is a deliberate platform-specific exception to reference-app shortcut parity. +Settings uses ⌘, rather than ⌘K on macOS. The changes apply to defaults; saved +custom assignments are not rewritten. The existing Keyboard Shortcuts editor can +restore a preferred creative binding. Such custom assignments can conflict with +system menu actions; check the effective menu shortcuts after customising them. + +The command registry, shortcut editor and displayed menu items use the same defaults. +This change addresses the listed conflicts; it does not certify every shortcut, +keyboard layout, accessibility feature or window behaviour. + +## References + +- [Apple keyboard guidance](https://developer.apple.com/design/human-interface-guidelines/keyboards) +- [Apple Mac shortcuts](https://support.apple.com/en-us/102650) +- [Published reference-app shortcuts](https://helpx.adobe.com/photoshop/using/default-keyboard-shortcuts.html) +- [Suite tracking issue](https://github.com/storytold/designcraft/issues/1317) + +The reference is published documentation only. No proprietary application or its +assets were used to implement these mappings. From 3fc96650f58953c4f3b3eeb1e9f90895d4e41eae Mon Sep 17 00:00:00 2001 From: Andee Collard Date: Wed, 21 Oct 2026 11:56:31 +0100 Subject: [PATCH 2/8] macOS menu: a saved Cmd+, takes the key from Settings A restored profile can give Hide Layers Cmd+, (Photoshop's key) while Settings keeps its new macOS default. The native menu then showed Cmd+, on both, because the clash check read a key-to-command map that keeps only one owner. Find the other owner by scanning the menu items, and drop Cmd+, from Settings when it is taken, as the clash report already says. Key dispatch already favours the user's key (#1272). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/native_menu.rs | 32 ++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/native_menu.rs b/crates/ui-egui/src/native_menu.rs index b6fb68fd45..ea5a2fb37f 100644 --- a/crates/ui-egui/src/native_menu.rs +++ b/crates/ui-egui/src/native_menu.rs @@ -405,8 +405,14 @@ pub fn mac_layout(bar: &MenuBar, lang: Lang) -> Layout { menu.extend([Node::Item(it), Node::Separator]); } if let Some(s) = settings { + // Scan the items, not `bound`: a saved key (Hide Layers on ⌘,, as in Photoshop) and + // Settings' own default can both name ⌘,, and the map keeps only one of them. let own = node_ids(&s); - let comma = bound.get("Cmd+,").filter(|cmd| !own.contains(*cmd)).cloned(); + let comma = bar + .items() + .into_iter() + .find(|it| !own.contains(&it.id) && it.shortcut.as_deref().and_then(Chord::parse).is_some_and(|c| c.portable() == "Cmd+,")) + .map(|it| it.id.clone()); menu.push(settings_node(s, comma, lang, &mut clashes)); } menu.extend(appearance); @@ -495,9 +501,14 @@ fn settings_node(node: Node, comma_taken: Option, lang: Lang, clashes: & if let Some(command) = &comma_taken { clashes.push(Clash { shortcut: "Cmd+,", system: "Settings", command: command.clone(), resolution: "Settings has no shortcut" }); } + // Another command's ⌘, wins: Settings drops the key even when it is Settings' own default. let give = |it: &mut Item| { - if comma_taken.is_none() && it.shortcut.is_none() { - it.shortcut = Some("Cmd+,".into()); + if comma_taken.is_none() { + if it.shortcut.is_none() { + it.shortcut = Some("Cmd+,".into()); + } + } else if it.shortcut.as_deref().and_then(Chord::parse).is_some_and(|c| c.portable() == "Cmd+,") { + it.shortcut = None; } }; match node { @@ -858,6 +869,21 @@ mod tests { assert!(!file.children.contains(&Node::Standard(Standard::CloseWindow)), "⌘W stays File › Close"); } + /// A restored profile that gives Hide Layers ⌘, (Photoshop's key) while Settings keeps its + /// macOS default: the saved key wins and Settings drops ⌘, rather than sharing it. + #[test] + fn a_saved_cmd_comma_takes_the_key_from_settings() { + let mut a = app(true); + // Loaded as saved, not set through Edit › Keyboard Shortcuts (which would clear Settings' row). + a.session.prefs.edit(|p| p.shortcuts.insert("layer.hideLayers".into(), "Cmd+,".into())); + let l = photocraft_layout(&crate::menus::menu_items(&a), Lang::EN, "auto"); + let comma: Vec<&str> = l.bar.items().into_iter().filter(|it| it.shortcut.as_deref() == Some("Cmd+,")).map(|it| it.id.as_str()).collect(); + assert_eq!(comma, ["layer.hideLayers"]); + assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut, None); + let clash = l.clashes.iter().find(|c| c.shortcut == "Cmd+,").unwrap(); + assert_eq!((clash.command.as_str(), clash.resolution), ("layer.hideLayers", "Settings has no shortcut")); + } + #[test] fn platform_defaults_keep_mac_actions_and_creative_actions_separate() { let a = app(true); From 1b81d354127ff27bbaf5d59aa70206ee2ee32b13 Mon Sep 17 00:00:00 2001 From: Andee Collard Date: Wed, 21 Oct 2026 12:12:10 +0100 Subject: [PATCH 3/8] macOS menu: find Cmd+, owners before items move to the app menu About, Quit and the Appearance items leave the bar before Settings is placed, so a saved Cmd+, on one of them went unseen and Settings kept the key too. Read every Cmd+, owner from the full menu first. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/native_menu.rs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/native_menu.rs b/crates/ui-egui/src/native_menu.rs index ea5a2fb37f..00beee8753 100644 --- a/crates/ui-egui/src/native_menu.rs +++ b/crates/ui-egui/src/native_menu.rs @@ -388,6 +388,14 @@ pub fn mac_layout(bar: &MenuBar, lang: Lang) -> Layout { let mut clashes = Vec::new(); let bound: HashMap = bar.items().iter().filter_map(|it| Some((Chord::parse(it.shortcut.as_deref()?)?.portable(), it.id.clone()))).collect(); let taken = |sc: &str, own: Option<&str>| bound.get(sc).filter(|cmd| Some(cmd.as_str()) != own).cloned(); + // Every ⌘, owner, read before About, Quit and Appearance leave the bar: `bound` keeps only one + // per key, and a saved key (Hide Layers on ⌘,, as in Photoshop) can share it with Settings. + let comma_owners: Vec = bar + .items() + .into_iter() + .filter(|it| it.shortcut.as_deref().and_then(Chord::parse).is_some_and(|c| c.portable() == "Cmd+,")) + .map(|it| it.id.clone()) + .collect(); let named = |s: &str| crate::i18n::fmt(tr(lang, s), &[("app", APP_NAME)]); let about = take(&mut bar, |n| matches!(n, Node::Item(it) if it.role == Some(ItemRole::About))); @@ -405,14 +413,8 @@ pub fn mac_layout(bar: &MenuBar, lang: Lang) -> Layout { menu.extend([Node::Item(it), Node::Separator]); } if let Some(s) = settings { - // Scan the items, not `bound`: a saved key (Hide Layers on ⌘,, as in Photoshop) and - // Settings' own default can both name ⌘,, and the map keeps only one of them. let own = node_ids(&s); - let comma = bar - .items() - .into_iter() - .find(|it| !own.contains(&it.id) && it.shortcut.as_deref().and_then(Chord::parse).is_some_and(|c| c.portable() == "Cmd+,")) - .map(|it| it.id.clone()); + let comma = comma_owners.iter().find(|id| !own.contains(*id)).cloned(); menu.push(settings_node(s, comma, lang, &mut clashes)); } menu.extend(appearance); @@ -884,6 +886,18 @@ mod tests { assert_eq!((clash.command.as_str(), clash.resolution), ("layer.hideLayers", "Settings has no shortcut")); } + /// The same for an item that moves to the app menu ahead of Settings (About). + #[test] + fn a_saved_cmd_comma_on_about_takes_the_key_from_settings() { + let mut a = app(true); + a.session.prefs.edit(|p| p.shortcuts.insert("help.about".into(), "Cmd+,".into())); + let l = photocraft_layout(&crate::menus::menu_items(&a), Lang::EN, "auto"); + let comma: Vec<&str> = l.bar.items().into_iter().filter(|it| it.shortcut.as_deref() == Some("Cmd+,")).map(|it| it.id.as_str()).collect(); + assert_eq!(comma, ["help.about"]); + assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut, None); + assert_eq!(l.clashes.iter().find(|c| c.shortcut == "Cmd+,").map(|c| c.command.as_str()), Some("help.about")); + } + #[test] fn platform_defaults_keep_mac_actions_and_creative_actions_separate() { let a = app(true); From 013b3fb7d7043477359ace7778dd175563cfff9a Mon Sep 17 00:00:00 2001 From: Andee Collard Date: Wed, 21 Oct 2026 12:31:59 +0100 Subject: [PATCH 4/8] macOS menu: a Cmd+, on a command with no menu item hides it from Settings Key equivalents come back as key presses, and dispatch gives a saved key to its command (#1272), so a Cmd+, saved on a command with no menu item (Fill with Foreground, say) ran that command while the menu bar still showed Cmd+, on Settings. The live menu bar now comes from app_layout, which checks the dispatch owner and clears Cmd+, from the menu when that owner has no menu item. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft/src/mac_menu.rs | 2 +- crates/ui-egui/src/native_menu.rs | 49 ++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/apps/photocraft/src/mac_menu.rs b/apps/photocraft/src/mac_menu.rs index f8a7c8c689..aea005753e 100644 --- a/apps/photocraft/src/mac_menu.rs +++ b/apps/photocraft/src/mac_menu.rs @@ -254,7 +254,7 @@ impl Backend for MacMenu { pub fn install(ctx: &egui::Context, app: &photocraft_ui_egui::PhotocraftApp) -> Option { let language = &app.session.prefs().interface.language; let lang = photocraft_ui_egui::i18n::Lang::from_pref(language); - let bar = native_menu::photocraft_layout(&photocraft_ui_egui::menus::menu_items(app), lang, language).bar; + let bar = native_menu::app_layout(app, &photocraft_ui_egui::menus::menu_items(app), lang, language).bar; // Never crash for a menu: if AppKit refuses, keep the in-window menus. let built = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { let mut menu = MacMenu::new(ctx); diff --git a/crates/ui-egui/src/native_menu.rs b/crates/ui-egui/src/native_menu.rs index 00beee8753..bd7ac04631 100644 --- a/crates/ui-egui/src/native_menu.rs +++ b/crates/ui-egui/src/native_menu.rs @@ -636,6 +636,31 @@ pub fn photocraft_layout(items: &[MenuItem], lang: Lang, language: &str) -> Layo layout } +/// [`photocraft_layout`] for the running app. A key equivalent comes back as a key press +/// ([`NativeMenu::raw_input`]), so a ⌘, the user gave a command with no menu item (Fill with +/// Foreground's key, say) runs that command: no menu item may show ⌘, then. +pub fn app_layout(app: &PhotocraftApp, items: &[MenuItem], lang: Lang, language: &str) -> Layout { + fn clear(nodes: &mut [Node]) { + for n in nodes { + match n { + Node::Item(it) if it.shortcut.as_deref() == Some("Cmd+,") => it.shortcut = None, + Node::Submenu { children, .. } => clear(children), + _ => {} + } + } + } + let mut layout = photocraft_layout(items, lang, language); + let comma = crate::shortcuts::parse("Cmd+,"); + let owner = crate::shortcut_dispatch::bindings(app).into_iter().find(|(_, sc)| Some(*sc) == comma).map(|(id, _)| id); + if let Some(command) = owner.filter(|id| layout.bar.find(id).is_none()) { + for m in &mut layout.bar.menus { + clear(&mut m.children); + } + layout.clashes.push(Clash { shortcut: "Cmd+,", system: "Settings", command, resolution: "Settings has no shortcut" }); + } + layout +} + // ----------------------------------------------------------------------------- the app's side /// What the native menu reports. @@ -734,7 +759,7 @@ pub fn sync(app: &mut PhotocraftApp, ctx: &egui::Context) { for it in &mut items { it.enabled &= crate::menus::modal_allows(app, &it.id); } - let layout = photocraft_layout(&items, lang, &app.session.prefs().interface.language); + let layout = app_layout(app, &items, lang, &app.session.prefs().interface.language); let Some(menu) = app.services.native_menu.as_mut() else { return }; if !menu.logged { for c in &layout.clashes { @@ -886,6 +911,28 @@ mod tests { assert_eq!((clash.command.as_str(), clash.resolution), ("layer.hideLayers", "Settings has no shortcut")); } + /// A saved ⌘, on a command with no menu item: the key press runs that command, so the live + /// menu bar must not show ⌘, on Settings. + #[test] + fn a_saved_cmd_comma_without_a_menu_item_takes_the_key_from_settings() { + let mut a = app(true); + a.session.prefs.edit(|p| p.shortcuts.insert("edit.fillForeground".into(), "Cmd+,".into())); + let items = crate::menus::menu_items(&a); + assert!(!items.iter().any(|it| it.id == "edit.fillForeground"), "the test needs a command with no menu item"); + let comma = crate::shortcuts::parse("Cmd+,"); + let keys = crate::shortcut_dispatch::bindings(&a); + assert_eq!(keys.iter().find(|(_, sc)| Some(*sc) == comma).map(|(id, _)| id.as_str()), Some("edit.fillForeground")); + let l = app_layout(&a, &items, Lang::EN, "auto"); + assert!(l.bar.items().iter().all(|it| it.shortcut.as_deref() != Some("Cmd+,"))); + assert_eq!(l.clashes.iter().find(|c| c.shortcut == "Cmd+,").map(|c| c.command.as_str()), Some("edit.fillForeground")); + if cfg!(target_os = "macos") { + // Without that key, Settings keeps its ⌘, default. + let plain = app(true); + let l = app_layout(&plain, &crate::menus::menu_items(&plain), Lang::EN, "auto"); + assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+,")); + } + } + /// The same for an item that moves to the app menu ahead of Settings (About). #[test] fn a_saved_cmd_comma_on_about_takes_the_key_from_settings() { From b7d3b7ca51cf1895d8c33d3833b453534c364bdc Mon Sep 17 00:00:00 2001 From: andeecollard Date: Fri, 23 Oct 2026 10:58:07 +0100 Subject: [PATCH 5/8] macOS menus: honor saved Hide, Minimize and alternate Settings bindings --- crates/ui-egui/src/native_menu.rs | 70 ++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/native_menu.rs b/crates/ui-egui/src/native_menu.rs index bd7ac04631..b840fc8383 100644 --- a/crates/ui-egui/src/native_menu.rs +++ b/crates/ui-egui/src/native_menu.rs @@ -636,27 +636,38 @@ pub fn photocraft_layout(items: &[MenuItem], lang: Lang, language: &str) -> Layo layout } -/// [`photocraft_layout`] for the running app. A key equivalent comes back as a key press -/// ([`NativeMenu::raw_input`]), so a ⌘, the user gave a command with no menu item (Fill with -/// Foreground's key, say) runs that command: no menu item may show ⌘, then. +/// Build native menus against effective dispatch ownership, including alternate shortcuts +/// and commands without menu items. AppKit must not consume a saved creative shortcut. pub fn app_layout(app: &PhotocraftApp, items: &[MenuItem], lang: Lang, language: &str) -> Layout { - fn clear(nodes: &mut [Node]) { - for n in nodes { - match n { - Node::Item(it) if it.shortcut.as_deref() == Some("Cmd+,") => it.shortcut = None, - Node::Submenu { children, .. } => clear(children), + fn clear(nodes: &mut [Node], key: &str, owner: &str, lang: Lang) { + let parsed = crate::shortcuts::parse(key); + for node in nodes { + match node { + Node::Item(it) if it.id != owner && it.shortcut.as_deref().and_then(crate::shortcuts::parse) == parsed => it.shortcut = None, + Node::Standard(Standard::Minimize) if key == "Cmd+M" => { + let mut item = Item::new(MINIMIZE, tr(lang, "Minimize")); + item.role = Some(ItemRole::Minimize); + *node = Node::Item(item); + } + Node::Submenu { children, .. } => clear(children, key, owner, lang), _ => {} } } } let mut layout = photocraft_layout(items, lang, language); - let comma = crate::shortcuts::parse("Cmd+,"); - let owner = crate::shortcut_dispatch::bindings(app).into_iter().find(|(_, sc)| Some(*sc) == comma).map(|(id, _)| id); - if let Some(command) = owner.filter(|id| layout.bar.find(id).is_none()) { - for m in &mut layout.bar.menus { - clear(&mut m.children); + let bindings = crate::shortcut_dispatch::bindings(app); + for (key, system) in [("Cmd+,", "Settings"), ("Cmd+H", "Hide"), ("Cmd+M", "Minimize"), ("Ctrl+Cmd+H", "Hide"), ("Ctrl+Cmd+M", "Minimize")] { + let parsed = crate::shortcuts::parse(key); + let owner = bindings.iter().find(|(_, sc)| Some(*sc) == parsed).map(|(id, _)| id); + if let Some(command) = owner { + let displayed = layout.bar.find(command).and_then(|it| it.shortcut.as_deref()).and_then(crate::shortcuts::parse); + if displayed != parsed { + for menu in &mut layout.bar.menus { + clear(&mut menu.children, key, command, lang); + } + layout.clashes.push(Clash { shortcut: key, system, command: command.clone(), resolution: "System menu yields to saved command" }); + } } - layout.clashes.push(Clash { shortcut: "Cmd+,", system: "Settings", command, resolution: "Settings has no shortcut" }); } layout } @@ -933,6 +944,37 @@ mod tests { } } + #[test] + fn saved_hide_and_minimize_keys_without_menu_items_reach_dispatch() { + for key in ["Cmd+H", "Cmd+M"] { + let mut a = app(true); + a.session.prefs.edit(|p| p.shortcuts.insert("edit.fillForeground".into(), key.into())); + let items = crate::menus::menu_items(&a); + assert!(!items.iter().any(|it| it.id == "edit.fillForeground")); + let parsed = crate::shortcuts::parse(key); + assert_eq!( + crate::shortcut_dispatch::bindings(&a).iter().find(|(_, sc)| Some(*sc) == parsed).map(|(id, _)| id.as_str()), + Some("edit.fillForeground") + ); + let layout = app_layout(&a, &items, Lang::EN, "auto"); + assert!(layout.bar.items().iter().all(|it| it.shortcut.as_deref().and_then(crate::shortcuts::parse) != parsed)); + assert!(!layout.bar.menu(MenuRole::Window).unwrap().children.contains(&Node::Standard(Standard::Minimize)) || key != "Cmd+M"); + } + } + + #[test] + fn a_saved_alternate_on_a_visible_command_removes_settings_comma() { + let mut a = app(true); + a.session.prefs.edit(|p| p.alternate_shortcuts.insert("view.extras".into(), vec!["Cmd+,".into()])); + let items = crate::menus::menu_items(&a); + assert!(items.iter().any(|it| it.id == "view.extras")); + let comma = crate::shortcuts::parse("Cmd+,"); + assert_eq!(crate::shortcut_dispatch::bindings(&a).iter().find(|(_, sc)| Some(*sc) == comma).map(|(id, _)| id.as_str()), Some("view.extras")); + let layout = app_layout(&a, &items, Lang::EN, "auto"); + assert!(layout.bar.items().iter().all(|it| it.shortcut.as_deref().and_then(crate::shortcuts::parse) != comma)); + assert_eq!(a.session.prefs.get().alternate_shortcuts["view.extras"], ["Cmd+,"]); + } + /// The same for an item that moves to the app menu ahead of Settings (About). #[test] fn a_saved_cmd_comma_on_about_takes_the_key_from_settings() { From d065b7647b53bb86fa87c84ba6288d67874df27d Mon Sep 17 00:00:00 2001 From: Andee Collard Date: Sat, 24 Oct 2026 11:44:47 +0100 Subject: [PATCH 6/8] macOS menu tests: hold on Linux and Windows, where Hide Layers owns Cmd+, by default Outside macOS, Hide Layers' default key is Cmd+, (Ctrl+,) and Settings uses Cmd+K, so three Cmd+, tests found a second owner or Settings' own key. Unbind Hide Layers where it isn't the subject, and check that Settings doesn't show Cmd+, rather than that it has no key. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/native_menu.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/native_menu.rs b/crates/ui-egui/src/native_menu.rs index b840fc8383..64bdc10dd1 100644 --- a/crates/ui-egui/src/native_menu.rs +++ b/crates/ui-egui/src/native_menu.rs @@ -917,7 +917,8 @@ mod tests { let l = photocraft_layout(&crate::menus::menu_items(&a), Lang::EN, "auto"); let comma: Vec<&str> = l.bar.items().into_iter().filter(|it| it.shortcut.as_deref() == Some("Cmd+,")).map(|it| it.id.as_str()).collect(); assert_eq!(comma, ["layer.hideLayers"]); - assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut, None); + // None on macOS; elsewhere Settings keeps its own ⌘K. + assert_ne!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+,")); let clash = l.clashes.iter().find(|c| c.shortcut == "Cmd+,").unwrap(); assert_eq!((clash.command.as_str(), clash.resolution), ("layer.hideLayers", "Settings has no shortcut")); } @@ -927,7 +928,11 @@ mod tests { #[test] fn a_saved_cmd_comma_without_a_menu_item_takes_the_key_from_settings() { let mut a = app(true); - a.session.prefs.edit(|p| p.shortcuts.insert("edit.fillForeground".into(), "Cmd+,".into())); + a.session.prefs.edit(|p| { + p.shortcuts.insert("edit.fillForeground".into(), "Cmd+,".into()); + // Hide Layers' own default is ⌘, outside macOS: unbind it so the saved key is the only owner. + p.shortcuts.insert("layer.hideLayers".into(), String::new()); + }); let items = crate::menus::menu_items(&a); assert!(!items.iter().any(|it| it.id == "edit.fillForeground"), "the test needs a command with no menu item"); let comma = crate::shortcuts::parse("Cmd+,"); @@ -979,11 +984,15 @@ mod tests { #[test] fn a_saved_cmd_comma_on_about_takes_the_key_from_settings() { let mut a = app(true); - a.session.prefs.edit(|p| p.shortcuts.insert("help.about".into(), "Cmd+,".into())); + a.session.prefs.edit(|p| { + p.shortcuts.insert("help.about".into(), "Cmd+,".into()); + // As above: outside macOS, Hide Layers' default ⌘, would be a second owner. + p.shortcuts.insert("layer.hideLayers".into(), String::new()); + }); let l = photocraft_layout(&crate::menus::menu_items(&a), Lang::EN, "auto"); let comma: Vec<&str> = l.bar.items().into_iter().filter(|it| it.shortcut.as_deref() == Some("Cmd+,")).map(|it| it.id.as_str()).collect(); assert_eq!(comma, ["help.about"]); - assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut, None); + assert_ne!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+,")); assert_eq!(l.clashes.iter().find(|c| c.shortcut == "Cmd+,").map(|c| c.command.as_str()), Some("help.about")); } From 2a9e18e345e82680d1b07627ab285c263172d684 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 25 Oct 2026 22:01:36 +0000 Subject: [PATCH 7/8] Keep Photoshop's default shortcuts; keep the native-menu ownership fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review feedback on #7809: the macOS default set moves to an explicit opt-in shortcut set (separate change). This change keeps only the native-menu fixes: the menu bar reads key ownership from dispatch, so a saved key on a command with no menu item, or an alternate key, takes ⌘H, ⌘M or ⌘, from the system item. Defaults stay Photoshop's on every platform (⌘K Settings, ⌘H Extras, ⌘M Curves, ⌘, Hide Layers). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UfJUts45srnaLXxZffF12A --- crates/engine/src/commands.rs | 2 +- crates/engine/src/extra_cmds.rs | 2 +- crates/engine/src/prefs.rs | 2 +- crates/engine/src/shell_commands.rs | 8 +- crates/ui-egui/src/kys_import_tests.rs | 6 +- crates/ui-egui/src/layer_shortcut_tests.rs | 7 +- crates/ui-egui/src/menu_catalog.rs | 6 +- crates/ui-egui/src/native_menu.rs | 75 ++++++++----------- crates/ui-egui/src/shortcut_dispatch/tests.rs | 4 +- crates/ui-egui/src/shortcuts.rs | 2 - docs/macos-shortcuts.md | 42 ----------- 11 files changed, 43 insertions(+), 113 deletions(-) delete mode 100644 docs/macos-shortcuts.md diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index 80cd47261f..9b4d4a7472 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -1390,7 +1390,7 @@ fn build() -> Vec { menu: &["Image", "Adjustments"], shortcut: match kind { "levels" => Some("Cmd+L"), - "curves" => Some(crate::shell_commands::CURVES_SHORTCUT), + "curves" => Some("Cmd+M"), "hueSaturation" => Some("Cmd+U"), "colorBalance" => Some("Cmd+B"), "invert" => Some("Cmd+I"), diff --git a/crates/engine/src/extra_cmds.rs b/crates/engine/src/extra_cmds.rs index 7a24543c27..072a3d4417 100644 --- a/crates/engine/src/extra_cmds.rs +++ b/crates/engine/src/extra_cmds.rs @@ -1032,7 +1032,7 @@ pub fn specs() -> Vec { "layer.hideLayers", "Hide Layers", &["Layer"], - Some(crate::shell_commands::HIDE_LAYERS_SHORTCUT), + Some("Cmd+,"), r##"{"layer":id?} (shows them instead when every targeted layer is already hidden, so ⌘, toggles)"##, has_layer, hide_or_show diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index f3c237f596..ed8b7f148f 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -2584,7 +2584,7 @@ pub fn specs() -> Vec { ), spec!("prefs.reset", "Reset Preferences", [], None, r##"{"path":"section|section.key"?=everything}"##, prefs_reset, false), // Photoshop: ⌘K opens Preferences › General (⌘, is Layer › Hide Layers). - section!("edit.preferences.general", "General…", Some(crate::shell_commands::SETTINGS_SHORTCUT)), + section!("edit.preferences.general", "General…", Some("Cmd+K")), section!("edit.preferences.interface", "Interface…"), section!("edit.preferences.workspace", "Workspace…"), section!("edit.preferences.tools", "Tools…"), diff --git a/crates/engine/src/shell_commands.rs b/crates/engine/src/shell_commands.rs index d584b6d105..2bd765673f 100644 --- a/crates/engine/src/shell_commands.rs +++ b/crates/engine/src/shell_commands.rs @@ -5,12 +5,6 @@ //! list, conflicts, `.kys` import and export all work without the UI (the UI is a layer on //! top). The app's tests keep these tables equal to its own. -/// Mac defaults leave system actions on their usual Command shortcuts. -pub const SETTINGS_SHORTCUT: &str = if cfg!(target_os = "macos") { "Cmd+," } else { "Cmd+K" }; -pub const EXTRAS_SHORTCUT: &str = if cfg!(target_os = "macos") { "Ctrl+Cmd+H" } else { "Cmd+H" }; -pub const CURVES_SHORTCUT: &str = if cfg!(target_os = "macos") { "Ctrl+Cmd+M" } else { "Cmd+M" }; -pub const HIDE_LAYERS_SHORTCUT: &str = if cfg!(target_os = "macos") { "Ctrl+Cmd+," } else { "Cmd+," }; - /// Shell commands: id, label, menu path, default shortcut. pub const SHELL_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[ ("ui.symmetryTransform", "Transform Symmetry", &[], None), @@ -42,7 +36,7 @@ pub const SHELL_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[ ("view.show.guides", "Guides", &["View", "Show"], Some("Cmd+;")), ("view.snap", "Snap", &["View"], Some("Cmd+Shift+;")), ("view.lockGuides", "Lock Guides", &["View"], Some("Cmd+Alt+;")), - ("view.extras", "Extras", &["View"], Some(EXTRAS_SHORTCUT)), + ("view.extras", "Extras", &["View"], Some("Cmd+H")), ("view.show.targetPath", "Target Path", &["View", "Show"], Some("Cmd+Shift+H")), ("view.screenMode.cycle", "Cycle Screen Mode", &[], Some("F")), // Photoshop's interface brightness shortcuts: step through the four Pro themes. diff --git a/crates/ui-egui/src/kys_import_tests.rs b/crates/ui-egui/src/kys_import_tests.rs index 54c8d21c26..b31ee98e68 100644 --- a/crates/ui-egui/src/kys_import_tests.rs +++ b/crates/ui-egui/src/kys_import_tests.rs @@ -142,11 +142,7 @@ fn import_button_fills_the_dialog_and_ok_applies_the_set() { assert_eq!(h.state().ui.status, "", "the import failed"); let overrides = field(&h, "overrides"); assert_eq!(overrides["filter.blur.gaussianBlur"], json!("Cmd+Ctrl+Alt+G")); - if cfg!(target_os = "macos") { - assert_eq!(overrides["edit.preferences.general"], json!("Cmd+K"), "an imported legacy binding stays explicit on Mac"); - } else { - assert!(overrides.get("edit.preferences.general").is_none(), "Cmd+K is Preferences' default: {overrides}"); - } + assert!(overrides.get("edit.preferences.general").is_none(), "Cmd+K is Preferences' default: {overrides}"); assert_eq!(overrides["filter.lastFilter"], json!("Cmd+F")); assert!(overrides.get("edit.undo").is_none(), "Cmd+Z is the default again: {overrides}"); assert!(overrides.get("select.all").is_none(), "already the default: {overrides}"); diff --git a/crates/ui-egui/src/layer_shortcut_tests.rs b/crates/ui-egui/src/layer_shortcut_tests.rs index 27209d792c..96ab2520dc 100644 --- a/crates/ui-egui/src/layer_shortcut_tests.rs +++ b/crates/ui-egui/src/layer_shortcut_tests.rs @@ -30,12 +30,11 @@ fn active(app: &PhotocraftApp) -> &photocraft_doc::Layer { } #[test] -fn hide_layers_shortcut_toggles_visibility_without_taking_mac_settings() { +fn command_comma_toggles_the_layers_visibility() { let mut app = app(); - let mods = if cfg!(target_os = "macos") { Modifiers::COMMAND | Modifiers::CTRL } else { Modifiers::COMMAND }; - press(&mut app, Key::Comma, mods); + press(&mut app, Key::Comma, Modifiers::COMMAND); assert!(!active(&app).visible); - press(&mut app, Key::Comma, mods); + press(&mut app, Key::Comma, Modifiers::COMMAND); assert!(active(&app).visible); } diff --git a/crates/ui-egui/src/menu_catalog.rs b/crates/ui-egui/src/menu_catalog.rs index a8d6edff61..1d98028625 100644 --- a/crates/ui-egui/src/menu_catalog.rs +++ b/crates/ui-egui/src/menu_catalog.rs @@ -148,7 +148,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[ (&["Edit"], "Menus…", Some("Cmd+Alt+Shift+M"), "edit.menus"), (&["Edit"], "Toolbar…", None, "edit.toolbar"), (&["Edit"], "---", None, "---"), - (&["Edit", "Preferences"], "Settings…", Some(photocraft_engine::shell_commands::SETTINGS_SHORTCUT), "edit.preferences.general"), + (&["Edit", "Preferences"], "Settings…", Some("Cmd+K"), "edit.preferences.general"), (&["Edit", "Preferences"], "AI Integrations…", None, "edit.preferences.integrations"), (&["Edit", "Preferences"], "Interface…", None, "edit.preferences.interface"), (&["Edit", "Preferences"], "Workspace…", None, "edit.preferences.workspace"), @@ -183,7 +183,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[ (&["Image"], "---", None, "---"), (&["Image", "Adjustments"], "Brightness/Contrast…", None, "image.adjustments.brightnessContrast"), (&["Image", "Adjustments"], "Levels…", Some("Cmd+L"), "image.adjustments.levels"), - (&["Image", "Adjustments"], "Curves…", Some(photocraft_engine::shell_commands::CURVES_SHORTCUT), "image.adjustments.curves"), + (&["Image", "Adjustments"], "Curves…", Some("Cmd+M"), "image.adjustments.curves"), (&["Image", "Adjustments"], "Exposure…", None, "image.adjustments.exposure"), (&["Image", "Adjustments"], "Vibrance…", None, "image.adjustments.vibrance"), (&["Image", "Adjustments"], "Hue/Saturation…", Some("Cmd+U"), "image.adjustments.hueSaturation"), @@ -660,7 +660,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[ (&["View", "Screen Mode"], "Full Screen Mode With Menu Bar", None, "view.screenMode.fullScreenWithMenuBar"), (&["View", "Screen Mode"], "Full Screen Mode", None, "view.screenMode.fullScreen"), (&["View"], "---", None, "---"), - (&["View"], "Extras", Some(photocraft_engine::shell_commands::EXTRAS_SHORTCUT), "view.extras"), + (&["View"], "Extras", Some("Cmd+H"), "view.extras"), (&["View", "Show"], "Layer Edges", None, "view.show.layerEdges"), (&["View", "Show"], "Selection Edges", None, "view.show.selectionEdges"), (&["View", "Show"], "Target Path", Some("Cmd+Shift+H"), "view.show.targetPath"), diff --git a/crates/ui-egui/src/native_menu.rs b/crates/ui-egui/src/native_menu.rs index 64bdc10dd1..aa723d0993 100644 --- a/crates/ui-egui/src/native_menu.rs +++ b/crates/ui-egui/src/native_menu.rs @@ -9,8 +9,10 @@ //! use the same app menu; //! - **Window** gets Minimize, Zoom and Bring All to Front, with the open documents after it //! (where a Mac app lists its windows), and **Help** the system search field; -//! - Mac defaults leave ⌘H, ⌘M and ⌘, to Hide, Minimize and Settings. Explicit custom -//! bindings are preserved; clashes are reported and system items give way when needed. +//! - **clashes** with the system's keys (⌘H, ⌘M, ⌘W, ⌘,) are resolved in PhotoCraft's favour, and +//! reported; Hide and Minimize move to ⌃⌘H and ⌃⌘M, as Photoshop does. [`app_layout`] reads +//! who owns a key from dispatch, so a saved key on a command with no menu item, or an +//! alternate key, takes it from the system item too. //! //! **Keys stay with egui.** AppKit runs a menu's key equivalents before the window sees the key, //! which would skip PhotoCraft's key rules (text fields keep ⌘C/⌘V/⌘Z, dialogs and Camera Raw are @@ -884,15 +886,10 @@ mod tests { assert_eq!(titles, ["PhotoCraft", "File", "Edit", "Image", "Layer", "Type", "Select", "Filter", "View", "Window", "Help"]); } - /// Explicit saved creative bindings still take priority over the system fallbacks. + /// PhotoCraft keeps Photoshop's ⌘H, ⌘M, ⌘W and ⌘, (Hide Layers): the system items give way. #[test] fn clashes_are_resolved_in_photocrafts_favour() { - let mut a = app(true); - for (id, sc) in [("view.extras", "Cmd+H"), ("image.adjustments.curves", "Cmd+M"), ("layer.hideLayers", "Cmd+,"), ("edit.preferences.general", "Cmd+K")] - { - a.run("edit.keyboardShortcuts", json!({"set": {id: sc}})).unwrap(); - } - let l = photocraft_layout(&crate::menus::menu_items(&a), Lang::EN, "auto"); + let l = layout(true); let clash = |sc: &str| l.clashes.iter().find(|c| c.shortcut == sc).map(|c| c.command.as_str()); assert_eq!(clash("Cmd+H"), Some("view.extras")); assert_eq!(clash("Cmd+M"), Some("image.adjustments.curves")); @@ -907,18 +904,16 @@ mod tests { assert!(!file.children.contains(&Node::Standard(Standard::CloseWindow)), "⌘W stays File › Close"); } - /// A restored profile that gives Hide Layers ⌘, (Photoshop's key) while Settings keeps its - /// macOS default: the saved key wins and Settings drops ⌘, rather than sharing it. + /// Settings saved on ⌘, (a restored profile) while Hide Layers keeps Photoshop's ⌘,: the menu + /// shows ⌘, once, on Hide Layers, rather than on both. #[test] - fn a_saved_cmd_comma_takes_the_key_from_settings() { + fn a_saved_cmd_comma_on_settings_gives_way_to_hide_layers() { let mut a = app(true); - // Loaded as saved, not set through Edit › Keyboard Shortcuts (which would clear Settings' row). - a.session.prefs.edit(|p| p.shortcuts.insert("layer.hideLayers".into(), "Cmd+,".into())); + // Loaded as saved, not set through Edit › Keyboard Shortcuts (which would clear Hide Layers' row). + a.session.prefs.edit(|p| p.shortcuts.insert("edit.preferences.general".into(), "Cmd+,".into())); let l = photocraft_layout(&crate::menus::menu_items(&a), Lang::EN, "auto"); let comma: Vec<&str> = l.bar.items().into_iter().filter(|it| it.shortcut.as_deref() == Some("Cmd+,")).map(|it| it.id.as_str()).collect(); assert_eq!(comma, ["layer.hideLayers"]); - // None on macOS; elsewhere Settings keeps its own ⌘K. - assert_ne!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+,")); let clash = l.clashes.iter().find(|c| c.shortcut == "Cmd+,").unwrap(); assert_eq!((clash.command.as_str(), clash.resolution), ("layer.hideLayers", "Settings has no shortcut")); } @@ -930,7 +925,7 @@ mod tests { let mut a = app(true); a.session.prefs.edit(|p| { p.shortcuts.insert("edit.fillForeground".into(), "Cmd+,".into()); - // Hide Layers' own default is ⌘, outside macOS: unbind it so the saved key is the only owner. + // Hide Layers' own default is ⌘,: unbind it so the saved key is the only owner. p.shortcuts.insert("layer.hideLayers".into(), String::new()); }); let items = crate::menus::menu_items(&a); @@ -941,12 +936,12 @@ mod tests { let l = app_layout(&a, &items, Lang::EN, "auto"); assert!(l.bar.items().iter().all(|it| it.shortcut.as_deref() != Some("Cmd+,"))); assert_eq!(l.clashes.iter().find(|c| c.shortcut == "Cmd+,").map(|c| c.command.as_str()), Some("edit.fillForeground")); - if cfg!(target_os = "macos") { - // Without that key, Settings keeps its ⌘, default. - let plain = app(true); - let l = app_layout(&plain, &crate::menus::menu_items(&plain), Lang::EN, "auto"); - assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+,")); - } + // With ⌘, free there is no clash, and Settings keeps Photoshop's ⌘K. + let mut free = app(true); + free.session.prefs.edit(|p| p.shortcuts.insert("layer.hideLayers".into(), String::new())); + let l = app_layout(&free, &crate::menus::menu_items(&free), Lang::EN, "auto"); + assert!(!l.clashes.iter().any(|c| c.shortcut == "Cmd+,")); + assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+K")); } #[test] @@ -986,7 +981,7 @@ mod tests { let mut a = app(true); a.session.prefs.edit(|p| { p.shortcuts.insert("help.about".into(), "Cmd+,".into()); - // As above: outside macOS, Hide Layers' default ⌘, would be a second owner. + // As above: Hide Layers' default ⌘, would be a second owner. p.shortcuts.insert("layer.hideLayers".into(), String::new()); }); let l = photocraft_layout(&crate::menus::menu_items(&a), Lang::EN, "auto"); @@ -996,29 +991,21 @@ mod tests { assert_eq!(l.clashes.iter().find(|c| c.shortcut == "Cmd+,").map(|c| c.command.as_str()), Some("help.about")); } + /// The default bindings are Photoshop's on every platform: the menu fixes change who shows a + /// key, not which command a key runs. #[test] - fn platform_defaults_keep_mac_actions_and_creative_actions_separate() { + fn photoshop_defaults_hold_on_every_platform() { let a = app(true); let keys = crate::shortcut_dispatch::bindings(&a); let binding = |key: &str| keys.iter().find(|(_, sc)| Some(*sc) == crate::shortcuts::parse(key)).map(|(id, _)| id.as_str()); - if cfg!(target_os = "macos") { - assert_eq!(binding("Cmd+,"), Some("edit.preferences.general")); - assert_eq!(binding("Cmd+H"), None); - assert_eq!(binding("Cmd+M"), None); - assert_eq!(binding("Ctrl+Cmd+H"), Some("view.extras")); - assert_eq!(binding("Ctrl+Cmd+M"), Some("image.adjustments.curves")); - assert_eq!(binding("Ctrl+Cmd+,"), Some("layer.hideLayers")); - let l = layout(true); - assert_eq!(l.bar.find(HIDE).unwrap().shortcut.as_deref(), Some("Cmd+H")); - assert!(l.bar.menu(MenuRole::Window).unwrap().children.contains(&Node::Standard(Standard::Minimize))); - assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+,")); - assert!(!l.clashes.iter().any(|c| ["Cmd+H", "Cmd+M", "Cmd+,"].contains(&c.shortcut))); - } else { - assert_eq!(binding("Cmd+K"), Some("edit.preferences.general")); - assert_eq!(binding("Cmd+H"), Some("view.extras")); - assert_eq!(binding("Cmd+M"), Some("image.adjustments.curves")); - assert_eq!(binding("Cmd+,"), Some("layer.hideLayers")); - } + assert_eq!(binding("Cmd+K"), Some("edit.preferences.general")); + assert_eq!(binding("Cmd+H"), Some("view.extras")); + assert_eq!(binding("Cmd+M"), Some("image.adjustments.curves")); + assert_eq!(binding("Cmd+,"), Some("layer.hideLayers")); + let l = app_layout(&a, &crate::menus::menu_items(&a), Lang::EN, "auto"); + assert_eq!(l.bar.find(HIDE).unwrap().shortcut.as_deref(), Some("Ctrl+Cmd+H")); + assert_eq!(l.bar.find(MINIMIZE).unwrap().shortcut.as_deref(), Some("Ctrl+Cmd+M")); + assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+K")); } /// Themes and the appearance-mode cycle move from Window to the app menu's Appearance. @@ -1084,7 +1071,7 @@ mod tests { assert_eq!(sc("edit.undo").as_deref(), Some("Cmd+Z")); assert_eq!(sc("edit.copy").as_deref(), Some("Cmd+C")); assert_eq!(sc("edit.paste").as_deref(), Some("Cmd+V")); - assert_eq!(sc("layer.hideLayers").as_deref(), Some(photocraft_engine::shell_commands::HIDE_LAYERS_SHORTCUT)); + assert_eq!(sc("layer.hideLayers").as_deref(), Some("Cmd+,")); let app = app(true); let bindings = crate::shortcut_dispatch::bindings(&app); for it in crate::menus::menu_items(&app).iter().filter(|it| it.enabled) { diff --git a/crates/ui-egui/src/shortcut_dispatch/tests.rs b/crates/ui-egui/src/shortcut_dispatch/tests.rs index 37504f7c1b..00f1a120a3 100644 --- a/crates/ui-egui/src/shortcut_dispatch/tests.rs +++ b/crates/ui-egui/src/shortcut_dispatch/tests.rs @@ -265,9 +265,7 @@ fn common_shortcuts_work_after_clicking_panels() { assert_ne!(h.state().ui.panels.layers, layers, "{place:?}: F7 toggles Layers"); press(&mut h, "F7"); // Dialogs: Image Size (⌥⌘I, shown in the menu but unbound before #127) and Levels (⌘L). - for (sc, what) in - [("Cmd+Alt+I", "Image Size"), ("Cmd+Alt+C", "Canvas Size"), ("Cmd+L", "Levels"), (photocraft_engine::shell_commands::CURVES_SHORTCUT, "Curves")] - { + for (sc, what) in [("Cmd+Alt+I", "Image Size"), ("Cmd+Alt+C", "Canvas Size"), ("Cmd+L", "Levels"), ("Cmd+M", "Curves")] { press(&mut h, sc); assert_eq!(h.state().ui.dialogs.len(), 1, "{place:?}: {sc} opens {what}"); h.state_mut().ui.dialogs.clear(); diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index 81a91f8968..1ad8d6d92a 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -62,7 +62,6 @@ pub fn pretty(s: &str) -> String { .into_iter() .map(|p| match (p, mac) { ("Cmd", true) => "⌘".to_string(), - ("Ctrl", true) => "⌃".to_string(), ("Cmd", false) => "Ctrl".to_string(), ("Shift", true) => "⇧".to_string(), ("Alt", true) => "⌥".to_string(), @@ -936,7 +935,6 @@ mod tests { let mac = cfg!(target_os = "macos"); assert_eq!(pretty("Cmd+Shift+N"), if mac { "⌘⇧N" } else { "Ctrl+Shift+N" }); // Lone keys and inline-hint combos. - assert_eq!(pretty("Ctrl+Cmd+H"), if mac { "⌃⌘H" } else { "Ctrl+Ctrl+H" }); assert_eq!(pretty("Alt"), if mac { "⌥" } else { "Alt" }); assert_eq!(pretty("Shift+Alt"), if mac { "⇧⌥" } else { "Shift+Alt" }); assert_eq!(pretty("Enter"), if mac { "↩" } else { "Enter" }); diff --git a/docs/macos-shortcuts.md b/docs/macos-shortcuts.md deleted file mode 100644 index c06dcfc837..0000000000 --- a/docs/macos-shortcuts.md +++ /dev/null @@ -1,42 +0,0 @@ -# macOS keyboard conventions - -PhotoCraft keeps macOS application actions on their familiar shortcuts. Creative -commands that conflict use a Control–Command variant on macOS. Other platforms -keep their existing defaults. - -| Application action | macOS | -| --- | --- | -| Settings | ⌘, | -| Hide application | ⌘H | -| Hide others | ⌥⌘H | -| Minimize | ⌘M | -| Close document | ⌘W | -| Quit | ⌘Q | - -| Creative action | macOS default | Windows/Linux default | -| --- | --- | --- | -| Extras | ⌃⌘H | Ctrl+H | -| Curves | ⌃⌘M | Ctrl+M | -| Hide Layers | ⌃⌘, | Ctrl+, | - -## Compatibility and customisation - -This is a deliberate platform-specific exception to reference-app shortcut parity. -Settings uses ⌘, rather than ⌘K on macOS. The changes apply to defaults; saved -custom assignments are not rewritten. The existing Keyboard Shortcuts editor can -restore a preferred creative binding. Such custom assignments can conflict with -system menu actions; check the effective menu shortcuts after customising them. - -The command registry, shortcut editor and displayed menu items use the same defaults. -This change addresses the listed conflicts; it does not certify every shortcut, -keyboard layout, accessibility feature or window behaviour. - -## References - -- [Apple keyboard guidance](https://developer.apple.com/design/human-interface-guidelines/keyboards) -- [Apple Mac shortcuts](https://support.apple.com/en-us/102650) -- [Published reference-app shortcuts](https://helpx.adobe.com/photoshop/using/default-keyboard-shortcuts.html) -- [Suite tracking issue](https://github.com/storytold/designcraft/issues/1317) - -The reference is published documentation only. No proprietary application or its -assets were used to implement these mappings. From 71acb4c47e546bc47bb1918fce756041f256b97d Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 8 Nov 2026 18:51:36 +0100 Subject: [PATCH 8/8] native menu: test that an imported .kys set owns the system keys it binds (#7809) Review on #7809 asked for coverage of imported .kys bindings. The set moves Cmd+M to Levels and gives Fill Cmd+, as its second key; the menu bar shows Cmd+M on Levels only, Minimize keeps Ctrl+Cmd+M, Settings yields Cmd+, and the clash is reported. Fails without app_layout's dispatch ownership pass. Co-Authored-By: andeecollard <6765611+andeecollard@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/menus/native_menu/tests.rs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/ui-egui/src/menus/native_menu/tests.rs b/crates/ui-egui/src/menus/native_menu/tests.rs index b1da625ca8..ff635b8a24 100644 --- a/crates/ui-egui/src/menus/native_menu/tests.rs +++ b/crates/ui-egui/src/menus/native_menu/tests.rs @@ -170,6 +170,41 @@ fn photoshop_defaults_hold_on_every_platform() { assert_eq!(l.bar.find("edit.preferences.general").unwrap().shortcut.as_deref(), Some("Cmd+K")); } +/// A Photoshop `.kys` set imported through Edit › Keyboard Shortcuts moves ⌘M to Levels and gives +/// Fill ⌘, as its second key: each key runs the imported command, so ⌘M shows on Levels only, +/// Minimize keeps ⌃⌘M, and Settings drops ⌘, though Fill's row shows its first key. The set's +/// Hide Photoshop row is not ours and changes nothing. +#[test] +fn an_imported_kys_set_owns_the_system_keys_it_binds() { + const SET: &str = "\u{feff} + +\tCmd+M +\tShift+F5Cmd+, +\tCmd+H + +"; + let mut a = app(true); + let r = a.session.execute("edit.keyboardShortcuts", json!({"importKys": SET})).unwrap(); + assert_eq!(r["import"]["unknown"], json!(["Hide Photoshop"]), "{r}"); + let keys = crate::shortcut_dispatch::bindings(&a); + let owner = |key: &str| keys.iter().find(|(_, sc)| Some(*sc) == crate::shortcuts::parse(key)).map(|(id, _)| id.clone()); + assert_eq!(owner("Cmd+M").as_deref(), Some("image.adjustments.levels")); + let fill = owner("Cmd+,").unwrap(); + assert_eq!(fill, "edit.fill"); + let l = app_layout(&a, &crate::menus::menu_items(&a), Lang::EN, "auto"); + let showing = |key: &str| -> Vec { + let parsed = crate::shortcuts::parse(key); + l.bar.items().into_iter().filter(|it| it.shortcut.as_deref().and_then(crate::shortcuts::parse) == parsed).map(|it| it.id.clone()).collect() + }; + assert_eq!(showing("Cmd+M"), ["image.adjustments.levels"]); + assert!(showing("Cmd+,").is_empty(), "{:?}", showing("Cmd+,")); + assert_eq!(l.bar.find(&fill).unwrap().shortcut.as_deref(), Some("Shift+F5")); + assert_eq!(l.bar.find(MINIMIZE).unwrap().shortcut.as_deref(), Some("Ctrl+Cmd+M")); + assert_eq!(l.bar.find(HIDE).unwrap().shortcut.as_deref(), Some("Ctrl+Cmd+H")); + assert_eq!(showing("Cmd+H"), ["view.extras"], "Hide Photoshop was not imported"); + assert!(l.clashes.iter().any(|c| c.shortcut == "Cmd+," && c.command == fill)); +} + /// Themes and the appearance-mode cycle move from Window to the app menu's Appearance. #[test] fn themes_move_to_the_app_menus_appearance() {