Merge pull request #195 from hecrj/fix/macos-quit

Quit application when `Cmd+Q` is pressed on macOS
This commit is contained in:
Héctor Ramón 2020-02-20 05:51:01 +01:00 committed by GitHub
commit 8d63c49ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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: