Quit the NanoVG demo when pressing Escape, not any key.

The previous setup was making it hard to take screenshots.
This commit is contained in:
Patrick Walton 2020-05-15 19:14:32 -07:00
parent deee2436c1
commit abecb697be
1 changed files with 8 additions and 2 deletions

View File

@ -44,7 +44,7 @@ use std::time::Instant;
use surfman::{Connection, ContextAttributeFlags, ContextAttributes, GLVersion as SurfmanGLVersion};
use surfman::{SurfaceAccess, SurfaceType};
use winit::dpi::LogicalSize;
use winit::{Event, EventsLoop, WindowBuilder, WindowEvent};
use winit::{Event, EventsLoop, KeyboardInput, VirtualKeyCode, WindowBuilder, WindowEvent};
#[cfg(not(windows))]
use jemallocator;
@ -1586,7 +1586,13 @@ fn main() {
event_loop.poll_events(|event| {
match event {
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } |
Event::WindowEvent { event: WindowEvent::KeyboardInput { .. }, .. } => exit = true,
Event::WindowEvent {
event: WindowEvent::KeyboardInput {
input: KeyboardInput { virtual_keycode: Some(VirtualKeyCode::Escape), .. },
..
},
..
} => exit = true,
Event::WindowEvent { event: WindowEvent::CursorMoved { position, .. }, .. } => {
mouse_position = vec2f(position.x as f32, position.y as f32);
}