From abecb697be40885e6e23a4ec6c4c9d27c2cd91e7 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 15 May 2020 19:14:32 -0700 Subject: [PATCH] Quit the NanoVG demo when pressing Escape, not any key. The previous setup was making it hard to take screenshots. --- examples/canvas_nanovg/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/canvas_nanovg/src/main.rs b/examples/canvas_nanovg/src/main.rs index 0a238163..a8638235 100644 --- a/examples/canvas_nanovg/src/main.rs +++ b/examples/canvas_nanovg/src/main.rs @@ -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); }