Quit application when Cmd+Q is pressed on macOS
This commit is contained in:
parent
80fc8c286e
commit
2e457c394f
1 changed files with 13 additions and 0 deletions
|
|
@ -347,6 +347,19 @@ pub trait Application: Sized {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
*control_flow = ControlFlow::Exit;
|
*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")]
|
#[cfg(feature = "debug")]
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
input:
|
input:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue