summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-11-25 05:31:45 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-11-26 02:05:42 +0100
commitd612bf56784b41346f18ad9eda4f6d54d699dcb5 (patch)
tree091cc60b513067cc1d3c8254ed1bcd3072b8410e /core
parent08e0b9ffbd931928ad10c0147b84c09ce083276d (diff)
downloadiced-d612bf56784b41346f18ad9eda4f6d54d699dcb5.tar.gz
iced-d612bf56784b41346f18ad9eda4f6d54d699dcb5.tar.bz2
iced-d612bf56784b41346f18ad9eda4f6d54d699dcb5.zip
Rename `keyboard::ModifiersState` to `Modifiers`
Diffstat (limited to 'core')
-rw-r--r--core/src/keyboard.rs4
-rw-r--r--core/src/keyboard/event.rs8
-rw-r--r--core/src/keyboard/modifiers.rs (renamed from core/src/keyboard/modifiers_state.rs)17
3 files changed, 12 insertions, 17 deletions
diff --git a/core/src/keyboard.rs b/core/src/keyboard.rs
index b26bdb3d..61e017ad 100644
--- a/core/src/keyboard.rs
+++ b/core/src/keyboard.rs
@@ -1,8 +1,8 @@
//! Reuse basic keyboard types.
mod event;
mod key_code;
-mod modifiers_state;
+mod modifiers;
pub use event::Event;
pub use key_code::KeyCode;
-pub use modifiers_state::ModifiersState;
+pub use modifiers::Modifiers;
diff --git a/core/src/keyboard/event.rs b/core/src/keyboard/event.rs
index d142c3bc..0564c171 100644
--- a/core/src/keyboard/event.rs
+++ b/core/src/keyboard/event.rs
@@ -1,4 +1,4 @@
-use super::{KeyCode, ModifiersState};
+use super::{KeyCode, Modifiers};
/// A keyboard event.
///
@@ -14,7 +14,7 @@ pub enum Event {
key_code: KeyCode,
/// The state of the modifier keys
- modifiers: ModifiersState,
+ modifiers: Modifiers,
},
/// A keyboard key was released.
@@ -23,12 +23,12 @@ pub enum Event {
key_code: KeyCode,
/// The state of the modifier keys
- modifiers: ModifiersState,
+ modifiers: Modifiers,
},
/// A unicode character was received.
CharacterReceived(char),
/// The keyboard modifiers have changed.
- ModifiersChanged(ModifiersState),
+ ModifiersChanged(Modifiers),
}
diff --git a/core/src/keyboard/modifiers_state.rs b/core/src/keyboard/modifiers.rs
index 254013c3..d2a0500e 100644
--- a/core/src/keyboard/modifiers_state.rs
+++ b/core/src/keyboard/modifiers.rs
@@ -1,6 +1,6 @@
/// The current state of the keyboard modifiers.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
-pub struct ModifiersState {
+pub struct Modifiers {
/// Whether a shift key is pressed
pub shift: bool,
@@ -14,17 +14,14 @@ pub struct ModifiersState {
pub logo: bool,
}
-impl ModifiersState {
- /// Returns true if the current [`ModifiersState`] has a "command key"
- /// pressed.
+impl Modifiers {
+ /// Returns true if a "command key" is pressed in the [`Modifiers`].
///
/// 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;
@@ -35,11 +32,9 @@ impl ModifiersState {
is_pressed
}
- /// 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(&self, modifiers: ModifiersState) -> bool {
+ /// Returns true if the current [`Modifiers`] have at least the same
+ /// keys pressed as the provided ones, and false otherwise.
+ pub fn matches(&self, modifiers: Self) -> bool {
let shift = !modifiers.shift || self.shift;
let control = !modifiers.control || self.control;
let alt = !modifiers.alt || self.alt;