Introduce is_command_pressed to ModifiersState
This commit is contained in:
parent
3b2ed0d6f0
commit
86fa12229e
2 changed files with 21 additions and 1 deletions
|
|
@ -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.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue