diff options
author | 2024-01-16 13:28:00 +0100 | |
---|---|---|
committer | 2024-01-16 13:28:00 +0100 | |
commit | 64d1ce5532f55d152fa5819532a138da2dca1a39 (patch) | |
tree | 1a242bde122b5e715f2e980c5541353e2ae8b048 /futures | |
parent | 534c7dd7b0bc515c31b6de87b4aa6a35b44c46a0 (diff) | |
download | iced-64d1ce5532f55d152fa5819532a138da2dca1a39.tar.gz iced-64d1ce5532f55d152fa5819532a138da2dca1a39.tar.bz2 iced-64d1ce5532f55d152fa5819532a138da2dca1a39.zip |
Refactor `KeyCode` into `Key` and `Location`
Diffstat (limited to 'futures')
-rw-r--r-- | futures/src/keyboard.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/futures/src/keyboard.rs b/futures/src/keyboard.rs index 855eecd4..8e7da38f 100644 --- a/futures/src/keyboard.rs +++ b/futures/src/keyboard.rs @@ -1,6 +1,6 @@ //! Listen to keyboard events. use crate::core; -use crate::core::keyboard::{Event, KeyCode, Modifiers}; +use crate::core::keyboard::{Event, Key, Modifiers}; use crate::subscription::{self, Subscription}; use crate::MaybeSend; @@ -10,7 +10,7 @@ use crate::MaybeSend; /// If the function returns `None`, the key press will be simply /// ignored. pub fn on_key_press<Message>( - f: fn(KeyCode, Modifiers) -> Option<Message>, + f: fn(Key, Modifiers) -> Option<Message>, ) -> Subscription<Message> where Message: MaybeSend + 'static, @@ -22,12 +22,10 @@ where match (event, status) { ( core::Event::Keyboard(Event::KeyPressed { - key_code, - modifiers, - .. + key, modifiers, .. }), core::event::Status::Ignored, - ) => f(key_code, modifiers), + ) => f(key, modifiers), _ => None, } }) @@ -39,7 +37,7 @@ where /// If the function returns `None`, the key release will be simply /// ignored. pub fn on_key_release<Message>( - f: fn(KeyCode, Modifiers) -> Option<Message>, + f: fn(Key, Modifiers) -> Option<Message>, ) -> Subscription<Message> where Message: MaybeSend + 'static, @@ -51,11 +49,12 @@ where match (event, status) { ( core::Event::Keyboard(Event::KeyReleased { - key_code, + key, modifiers, + .. }), core::event::Status::Ignored, - ) => f(key_code, modifiers), + ) => f(key, modifiers), _ => None, } }) |