mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 21:00:04 -04:00
Implement new ControlFlow and associated events
This commit is contained in:
@@ -3,7 +3,7 @@ extern crate winit;
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
let mut events_loop = winit::EventLoop::new();
|
||||
let events_loop = winit::EventLoop::new();
|
||||
|
||||
let mut windows = HashMap::new();
|
||||
for _ in 0..3 {
|
||||
@@ -11,7 +11,8 @@ fn main() {
|
||||
windows.insert(window.id(), window);
|
||||
}
|
||||
|
||||
events_loop.run_forever(move |event, events_loop: &winit::EventLoop| {
|
||||
events_loop.run(move |event, events_loop, control_flow| {
|
||||
*control_flow = winit::ControlFlow::Wait;
|
||||
match event {
|
||||
winit::Event::WindowEvent { event, window_id } => {
|
||||
match event {
|
||||
@@ -22,7 +23,7 @@ fn main() {
|
||||
windows.remove(&window_id);
|
||||
|
||||
if windows.is_empty() {
|
||||
return winit::ControlFlow::Break;
|
||||
*control_flow = winit::ControlFlow::Exit;
|
||||
}
|
||||
},
|
||||
winit::WindowEvent::KeyboardInput{..} => {
|
||||
@@ -34,6 +35,5 @@ fn main() {
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
winit::ControlFlow::Continue
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user