26 lines
852 B
Rust
26 lines
852 B
Rust
// TODO: Add a method to the Window that returns the
|
|
// current modifier state.
|
|
|
|
/// The current state of the keyboard modifiers.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
|
pub struct ModifiersState {
|
|
pub shift: bool,
|
|
pub control: bool,
|
|
pub alt: bool,
|
|
pub logo: bool,
|
|
}
|
|
|
|
impl ModifiersState {
|
|
/// Returns true if the current [`ModifiersState`] has at least the same
|
|
/// modifiers enabled as the given value, and false otherwise.
|
|
///
|
|
/// [`ModifiersState`]: struct.ModifiersState.html
|
|
pub fn matches_atleast(&self, modifiers: ModifiersState) -> bool {
|
|
let shift = !modifiers.shift || self.shift;
|
|
let control = !modifiers.control || self.control;
|
|
let alt = !modifiers.alt || self.alt;
|
|
let logo = !modifiers.logo || self.logo;
|
|
|
|
shift && control && alt && logo
|
|
}
|
|
}
|