From ce5987d11490670a04c8648e2dd293a16af35dc1 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 11 Nov 2026 20:01:55 +0000 Subject: [PATCH] Collection keys: Enter activates and F2 renames on every platform The macOS rows that made Enter rename the lead and Cmd+Down activate it go. --- crates/behavior/src/keys.rs | 4 +--- crates/behavior/tests/key_table.rs | 17 +++++++++++++++++ crates/behavior/tests/main.rs | 1 + crates/layers/src/ui/panel/mod.rs | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 crates/behavior/tests/key_table.rs diff --git a/crates/behavior/src/keys.rs b/crates/behavior/src/keys.rs index 9605c95f8..f84bee741 100644 --- a/crates/behavior/src/keys.rs +++ b/crates/behavior/src/keys.rs @@ -237,9 +237,7 @@ pub fn intent(os: Os, key: Key, mods: Mods, role: KeyRole) -> Option { Key::Space if plain && role.space => return Some(Intent::Space), Key::Menu if plain && !mac => return Some(Intent::ContextMenu), Key::F10 if only(Mods::SHIFT) => return Some(Intent::ContextMenu), - Key::F2 if plain && role.rename && !mac => return Some(Intent::Rename), - Key::Enter if plain && role.rename && mac => return Some(Intent::Rename), - Key::Down if mac && role.rename && only(Mods::CMD) => return Some(Intent::Activate), + Key::F2 if plain && role.rename => return Some(Intent::Rename), Key::Enter if only(Mods::CMD) => return Some(Intent::SubmitForce), Key::Down if only(Mods::ALT) => return Some(Intent::Open), Key::Up if only(Mods::ALT) => return Some(Intent::Close), diff --git a/crates/behavior/tests/key_table.rs b/crates/behavior/tests/key_table.rs new file mode 100644 index 000000000..7406a666b --- /dev/null +++ b/crates/behavior/tests/key_table.rs @@ -0,0 +1,17 @@ +//! The key table's collection rows. + +use craft_behavior::Intent; +use craft_behavior::keys::{KeyRole, intent}; +use craft_host::target::Os; +use craft_keymap::{Key, Mods}; + +/// On every platform F2 renames the lead of a renamable collection and Enter is left to activation. +#[test] +fn f2_renames_and_enter_activates_on_every_platform() { + let role = KeyRole::new().rename(true).space(true).moves(true); + for os in [Os::Mac, Os::Windows, Os::Linux] { + assert_eq!(intent(os, Key::F2, Mods::NONE, role), Some(Intent::Rename), "{os:?}: F2 renames"); + assert_eq!(intent(os, Key::Enter, Mods::NONE, role), None, "{os:?}: Enter is activation, not rename"); + assert_ne!(intent(os, Key::Down, Mods::CMD, role), Some(Intent::Activate), "{os:?}: Cmd+Down does not activate"); + } +} diff --git a/crates/behavior/tests/main.rs b/crates/behavior/tests/main.rs index 67059036f..383b81de8 100644 --- a/crates/behavior/tests/main.rs +++ b/crates/behavior/tests/main.rs @@ -7,3 +7,4 @@ mod dock_apply; mod fit; #[path = "geometry/main.rs"] mod geometry; +mod key_table; diff --git a/crates/layers/src/ui/panel/mod.rs b/crates/layers/src/ui/panel/mod.rs index 25dfc8c29..120a40a31 100644 --- a/crates/layers/src/ui/panel/mod.rs +++ b/crates/layers/src/ui/panel/mod.rs @@ -137,7 +137,7 @@ impl Default for Session { /// /// - **Keys**: the rows are one Tab stop (the list's keys: arrows, Home, End and Page with Shift; /// Cmd/Ctrl moves the lead alone; Left and Right close and open a group, Alt for every group; -/// Cmd/Ctrl+] and [ move the selected layers, Shift to the ends; Enter activates; the per-OS rename key renames). The panel's +/// Cmd/Ctrl+] and [ move the selected layers, Shift to the ends; Enter activates; F2 renames). The panel's /// commands ([`LayersPanelCommands`]) are the app's: the stacking keys and the effects keys. /// - **Pointer**: clicks select (Cmd/Ctrl toggles, Shift extends, the empty space clears), the eye /// and lock columns sweep, Alt-click on an eye shows only that layer, the eye's right-click opens