mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Make docs set control_flow in a more realistic way (#1376)
This commit is contained in:
parent
02ac7456e4
commit
d15eb04f9e
|
@ -46,12 +46,14 @@ fn main() {
|
||||||
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
|
*control_flow = ControlFlow::Wait;
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::CloseRequested,
|
event: WindowEvent::CloseRequested,
|
||||||
window_id,
|
window_id,
|
||||||
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
|
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
|
||||||
_ => *control_flow = ControlFlow::Wait,
|
_ => (),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ fn main() {
|
||||||
|
|
||||||
while !quit {
|
while !quit {
|
||||||
event_loop.run_return(|event, _, control_flow| {
|
event_loop.run_return(|event, _, control_flow| {
|
||||||
|
*control_flow = ControlFlow::Wait;
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = &event {
|
if let Event::WindowEvent { event, .. } = &event {
|
||||||
// Print only Window events to reduce noise
|
// Print only Window events to reduce noise
|
||||||
println!("{:?}", event);
|
println!("{:?}", event);
|
||||||
|
@ -43,7 +45,7 @@ fn main() {
|
||||||
Event::MainEventsCleared => {
|
Event::MainEventsCleared => {
|
||||||
*control_flow = ControlFlow::Exit;
|
*control_flow = ControlFlow::Exit;
|
||||||
}
|
}
|
||||||
_ => *control_flow = ControlFlow::Wait,
|
_ => (),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,14 @@ pub use crate::icon::*;
|
||||||
/// let window = Window::new(&event_loop).unwrap();
|
/// let window = Window::new(&event_loop).unwrap();
|
||||||
///
|
///
|
||||||
/// event_loop.run(move |event, _, control_flow| {
|
/// event_loop.run(move |event, _, control_flow| {
|
||||||
|
/// *control_flow = ControlFlow::Wait;
|
||||||
|
///
|
||||||
/// match event {
|
/// match event {
|
||||||
/// Event::WindowEvent {
|
/// Event::WindowEvent {
|
||||||
/// event: WindowEvent::CloseRequested,
|
/// event: WindowEvent::CloseRequested,
|
||||||
/// ..
|
/// ..
|
||||||
/// } => *control_flow = ControlFlow::Exit,
|
/// } => *control_flow = ControlFlow::Exit,
|
||||||
/// _ => *control_flow = ControlFlow::Wait,
|
/// _ => (),
|
||||||
/// }
|
/// }
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Reference in a new issue