From f5c624bcd6dfb43586ab536d66c68db3d34a5760 Mon Sep 17 00:00:00 2001 From: aloucks Date: Tue, 9 Jul 2019 00:22:10 -0400 Subject: [PATCH] Handle RedrawRequested event in request_redraw example (#1030) --- examples/request_redraw.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/examples/request_redraw.rs b/examples/request_redraw.rs index 35ef4a12..ac9377e7 100644 --- a/examples/request_redraw.rs +++ b/examples/request_redraw.rs @@ -14,19 +14,21 @@ fn main() { .build(&event_loop) .unwrap(); - event_loop.run(move |event, _, control_flow| { - println!("{:?}", event); - - match event { - Event::WindowEvent { - event: WindowEvent::CloseRequested, - .. - } => *control_flow = ControlFlow::Exit, - Event::EventsCleared => { - window.request_redraw(); - *control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::new(1, 0)) - } - _ => (), + event_loop.run(move |event, _, control_flow| match event { + Event::WindowEvent { + event: WindowEvent::CloseRequested, + .. + } => *control_flow = ControlFlow::Exit, + Event::EventsCleared => { + window.request_redraw(); + *control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::new(1, 0)) } + Event::WindowEvent { + event: WindowEvent::RedrawRequested, + .. + } => { + println!("{:?}", event); + } + _ => (), }); }