Add ModifiersState to keyboard::Event::Input
This commit is contained in:
parent
31b0b7f580
commit
65cac922b3
6 changed files with 44 additions and 3 deletions
|
|
@ -319,6 +319,7 @@ pub trait Application: Sized {
|
|||
winit::event::KeyboardInput {
|
||||
virtual_keycode: Some(virtual_keycode),
|
||||
state,
|
||||
modifiers,
|
||||
..
|
||||
},
|
||||
..
|
||||
|
|
@ -334,6 +335,7 @@ pub trait Application: Sized {
|
|||
events.push(Event::Keyboard(keyboard::Event::Input {
|
||||
key_code: conversion::key_code(virtual_keycode),
|
||||
state: conversion::button_state(state),
|
||||
modifiers: conversion::modifiers_state(modifiers),
|
||||
}));
|
||||
}
|
||||
WindowEvent::CloseRequested => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
//! [`winit`]: https://github.com/rust-windowing/winit
|
||||
//! [`iced_native`]: https://github.com/hecrj/iced/tree/master/native
|
||||
use crate::{
|
||||
input::{keyboard::KeyCode, mouse, ButtonState},
|
||||
input::{
|
||||
keyboard::{KeyCode, ModifiersState},
|
||||
mouse, ButtonState,
|
||||
},
|
||||
MouseCursor,
|
||||
};
|
||||
|
||||
|
|
@ -47,6 +50,21 @@ pub fn button_state(element_state: winit::event::ElementState) -> ButtonState {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convert some `ModifiersState` from [`winit`] to an [`iced_native`] modifiers state.
|
||||
///
|
||||
/// [`winit`]: https://github.com/rust-windowing/winit
|
||||
/// [`iced_native`]: https://github.com/hecrj/iced/tree/master/native
|
||||
pub fn modifiers_state(
|
||||
modifiers: winit::event::ModifiersState,
|
||||
) -> ModifiersState {
|
||||
ModifiersState {
|
||||
shift: modifiers.shift,
|
||||
control: modifiers.ctrl,
|
||||
alt: modifiers.alt,
|
||||
logo: modifiers.logo,
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a `VirtualKeyCode` from [`winit`] to an [`iced_native`] key code.
|
||||
///
|
||||
/// [`winit`]: https://github.com/rust-windowing/winit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue