Quit application when `Cmd+Q` is pressed on macOS

This commit is contained in:
Héctor Ramón Jiménez 2020-02-19 14:53:08 +01:00
parent 80fc8c286e
commit 2e457c394f
1 changed files with 13 additions and 0 deletions

View File

@ -347,6 +347,19 @@ pub trait Application: Sized {
WindowEvent::CloseRequested => {
*control_flow = ControlFlow::Exit;
}
#[cfg(target_os = "macos")]
WindowEvent::KeyboardInput {
input:
winit::event::KeyboardInput {
virtual_keycode:
Some(winit::event::VirtualKeyCode::Q),
state: winit::event::ElementState::Pressed,
..
},
..
} if modifiers.logo() => {
*control_flow = ControlFlow::Exit;
}
#[cfg(feature = "debug")]
WindowEvent::KeyboardInput {
input: