Implement new ControlFlow and associated events

This commit is contained in:
Osspial
2018-08-17 17:31:04 -04:00
parent 8b8a7675ec
commit 02f922f003
14 changed files with 237 additions and 131 deletions

View File

@@ -3,14 +3,14 @@ extern crate winit;
use winit::{Event, EventLoop, ElementState, MouseCursor, WindowEvent, KeyboardInput, ControlFlow};
fn main() {
let mut events_loop = EventLoop::new();
let events_loop = EventLoop::new();
let window = winit::WindowBuilder::new().build(&events_loop).unwrap();
window.set_title("A fantastic window!");
let mut cursor_idx = 0;
events_loop.run_forever(move |event, _: &EventLoop| {
events_loop.run(move |event, _, control_flow| {
match event {
Event::WindowEvent { event: WindowEvent::KeyboardInput { input: KeyboardInput { state: ElementState::Pressed, .. }, .. }, .. } => {
println!("Setting cursor to \"{:?}\"", CURSORS[cursor_idx]);
@@ -22,11 +22,11 @@ fn main() {
}
},
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
return ControlFlow::Break;
*control_flow = ControlFlow::Exit;
return;
},
_ => ()
}
ControlFlow::Continue
});
}