Skip to content

Commit

Permalink
Make Logo + Q close the application
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatekii committed Nov 8, 2024
1 parent 1e129bb commit aaf2dcc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use osm::math::{deg2num, num_to_global_space};
use winit::{
dpi::PhysicalPosition,
event::{
ElementState, Event, KeyboardInput, MouseButton, MouseScrollDelta, VirtualKeyCode,
WindowEvent,
ElementState, Event, KeyboardInput, ModifiersState, MouseButton, MouseScrollDelta,
VirtualKeyCode, WindowEvent,
},
event_loop::ControlFlow,
};
Expand Down Expand Up @@ -52,6 +52,8 @@ fn main() {
let mut mouse_down = false;
let mut last_pos = winit::dpi::LogicalPosition::new(0.0, 0.0);

let mut modifiers_state = ModifiersState::default();

event_loop.run(move |event, _, control_flow| {
let ui_event = hud.interact(&event);
match event {
Expand All @@ -72,6 +74,10 @@ fn main() {
},
..
} => {
if keycode == VirtualKeyCode::Q && modifiers_state.logo() {
*control_flow = ControlFlow::Exit;
return;
}
if !ui_event {
match keycode {
VirtualKeyCode::Escape => {
Expand All @@ -82,6 +88,9 @@ fn main() {
}
}
}
WindowEvent::ModifiersChanged(state) => {
modifiers_state = state;
}
WindowEvent::CloseRequested => {
*control_flow = ControlFlow::Exit;
}
Expand Down

0 comments on commit aaf2dcc

Please sign in to comment.