gpu-tracing icon indicating copy to clipboard operation
gpu-tracing copied to clipboard

Close window with escape key

Open trevordblack opened this issue 1 year ago • 1 comments

         Event::WindowEvent {
             event: WindowEvent::KeyboardInput { input, .. },
             window_id,
         } if window_id == window.id() => {
             if input.virtual_keycode == Some(VirtualKeyCode::Escape) {
                 *control_flow = ControlFlow::Exit
             }
         }

trevordblack avatar Jul 13 '24 00:07 trevordblack

In newer versions of winit (0.29) this is done slightly differently:

event_loop.run(|event, control_target| {
        control_target.set_control_flow(ControlFlow::Poll);
        match event {
            Event::WindowEvent { event, .. } => match event {
                WindowEvent::CloseRequested => control_target.exit(),
                ...
            }
        ...

I.e., you can replace *control_flow = ControlFlow::Exit with control_target.exit().

armansito avatar Jul 13 '24 00:07 armansito