diff options
author | 2024-05-31 16:32:12 +0200 | |
---|---|---|
committer | 2024-05-31 16:32:12 +0200 | |
commit | 06ff17fcf87495663a295d1548df1c2ac03dafbd (patch) | |
tree | 5dbfe97e50662cdaf396427d7793c4f03fc159c6 /core/src | |
parent | 12f4b875cfb0eeb0bac5416921c6cec40edd420c (diff) | |
parent | 3312dc808012e2c049fb2f178d51bfe0b4e30399 (diff) | |
download | iced-06ff17fcf87495663a295d1548df1c2ac03dafbd.tar.gz iced-06ff17fcf87495663a295d1548df1c2ac03dafbd.tar.bz2 iced-06ff17fcf87495663a295d1548df1c2ac03dafbd.zip |
Merge pull request #2315 from Brady-Simon/macos-command-input-behavior
Add Command + ArrowLeft/Right input behavior for macOS
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/keyboard/modifiers.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/src/keyboard/modifiers.rs b/core/src/keyboard/modifiers.rs index e531510f..edbf6d38 100644 --- a/core/src/keyboard/modifiers.rs +++ b/core/src/keyboard/modifiers.rs @@ -84,4 +84,28 @@ impl Modifiers { is_pressed } + + /// Returns true if the "jump key" is pressed in the [`Modifiers`]. + /// + /// The "jump key" is the modifier key used to widen text motions. It is the `Alt` + /// key in macOS and the `Ctrl` key in other platforms. + pub fn jump(self) -> bool { + if cfg!(target_os = "macos") { + self.alt() + } else { + self.control() + } + } + + /// Returns true if the "command key" is pressed on a macOS device. + /// + /// This is relevant for macOS-specific actions (e.g. `⌘ + ArrowLeft` moves the cursor + /// to the beginning of the line). + pub fn macos_command(self) -> bool { + if cfg!(target_os = "macos") { + self.logo() + } else { + false + } + } } |