Merge pull request #430 from hecrj/feature/keyboard-modifiers-event

Add `ModifiersChanged` to `keyboard::Event`
This commit is contained in:
Héctor Ramón 2020-07-01 22:44:26 +02:00 committed by GitHub
commit 79aa225001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -28,4 +28,7 @@ pub enum Event {
/// A unicode character was received. /// A unicode character was received.
CharacterReceived(char), CharacterReceived(char),
/// The keyboard modifiers have changed.
ModifiersChanged(ModifiersState),
} }

View File

@ -539,10 +539,8 @@ where
} }
} }
} }
*self.pressed_modifiers = modifiers;
} }
keyboard::Event::KeyReleased { modifiers, .. } => { keyboard::Event::ModifiersChanged(modifiers) => {
*self.pressed_modifiers = modifiers; *self.pressed_modifiers = modifiers;
} }
_ => {} _ => {}

View File

@ -92,6 +92,9 @@ pub fn window_event(
} }
} }
})), })),
WindowEvent::ModifiersChanged(new_modifiers) => Some(Event::Keyboard(
keyboard::Event::ModifiersChanged(modifiers_state(*new_modifiers)),
)),
WindowEvent::HoveredFile(path) => { WindowEvent::HoveredFile(path) => {
Some(Event::Window(window::Event::FileHovered(path.clone()))) Some(Event::Window(window::Event::FileHovered(path.clone())))
} }