diff options
author | 2020-11-10 22:57:19 +0100 | |
---|---|---|
committer | 2020-11-10 22:57:19 +0100 | |
commit | 2f5a3dacd933a52931a1bb169138d52402413956 (patch) | |
tree | 65995b4304543ea6a6400af3c8e11eae630dd22b /core | |
parent | d0402d072d3f4e128c55fc0a6184c5f7c712bb20 (diff) | |
parent | 86fa12229e7117306b8297a09aa22c99802600c8 (diff) | |
download | iced-2f5a3dacd933a52931a1bb169138d52402413956.tar.gz iced-2f5a3dacd933a52931a1bb169138d52402413956.tar.bz2 iced-2f5a3dacd933a52931a1bb169138d52402413956.zip |
Merge pull request #608 from hecrj/remove-pane-grid-focus
Improve flexibility of `PaneGrid`
Diffstat (limited to 'core')
-rw-r--r-- | core/src/keyboard/modifiers_state.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/src/keyboard/modifiers_state.rs b/core/src/keyboard/modifiers_state.rs index 4d24266f..254013c3 100644 --- a/core/src/keyboard/modifiers_state.rs +++ b/core/src/keyboard/modifiers_state.rs @@ -15,6 +15,26 @@ pub struct ModifiersState { } impl ModifiersState { + /// Returns true if the current [`ModifiersState`] has a "command key" + /// pressed. + /// + /// The "command key" is the main modifier key used to issue commands in the + /// current platform. Specifically: + /// + /// - It is the `logo` or command key (⌘) on macOS + /// - It is the `control` key on other platforms + /// + /// [`ModifiersState`]: struct.ModifiersState.html + pub fn is_command_pressed(self) -> bool { + #[cfg(target_os = "macos")] + let is_pressed = self.logo; + + #[cfg(not(target_os = "macos"))] + let is_pressed = self.control; + + is_pressed + } + /// Returns true if the current [`ModifiersState`] has at least the same /// modifiers enabled as the given value, and false otherwise. /// |