diff --git a/examples/src/lib.rs b/examples/src/lib.rs index ab087e949..e88da2b3c 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -184,24 +184,24 @@ impl ExampleBase { self.event_loop .borrow_mut() .run_return(|event, _, control_flow| { - *control_flow = ControlFlow::Wait; - f(); - if let Event::WindowEvent { - event: - WindowEvent::CloseRequested - | WindowEvent::KeyboardInput { - input: - KeyboardInput { - state: ElementState::Pressed, - virtual_keycode: Some(VirtualKeyCode::Escape), - .. - }, - .. - }, - .. - } = event - { - *control_flow = ControlFlow::Exit + *control_flow = ControlFlow::Poll; + match event { + Event::WindowEvent { + event: + WindowEvent::CloseRequested + | WindowEvent::KeyboardInput { + input: + KeyboardInput { + state: ElementState::Pressed, + virtual_keycode: Some(VirtualKeyCode::Escape), + .. + }, + .. + }, + .. + } => *control_flow = ControlFlow::Exit, + Event::MainEventsCleared => f(), + _ => (), } }); }