2019-07-26 04:56:24 +10:00
|
|
|
// Limit this example to only compatible platforms.
|
|
|
|
#[cfg(any(
|
|
|
|
target_os = "windows",
|
|
|
|
target_os = "macos",
|
|
|
|
target_os = "linux",
|
|
|
|
target_os = "dragonfly",
|
|
|
|
target_os = "freebsd",
|
|
|
|
target_os = "netbsd",
|
|
|
|
target_os = "openbsd"
|
|
|
|
))]
|
2019-02-06 02:30:33 +11:00
|
|
|
fn main() {
|
2019-07-26 04:56:24 +10:00
|
|
|
use winit::{
|
|
|
|
event::{Event, WindowEvent},
|
|
|
|
event_loop::{ControlFlow, EventLoop},
|
|
|
|
platform::desktop::EventLoopExtDesktop,
|
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
|
|
|
|
2019-02-06 02:30:33 +11:00
|
|
|
let mut event_loop = EventLoop::new();
|
|
|
|
|
|
|
|
let window = WindowBuilder::new()
|
|
|
|
.with_title("A fantastic window!")
|
|
|
|
.build(&event_loop)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
println!("Close the window to continue.");
|
2019-06-25 02:14:55 +10:00
|
|
|
event_loop.run_return(|event, _, control_flow| match event {
|
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
|
|
|
..
|
|
|
|
} => *control_flow = ControlFlow::Exit,
|
|
|
|
_ => *control_flow = ControlFlow::Wait,
|
2019-02-06 02:30:33 +11:00
|
|
|
});
|
|
|
|
drop(window);
|
|
|
|
|
|
|
|
let _window_2 = WindowBuilder::new()
|
|
|
|
.with_title("A second, fantasticer window!")
|
|
|
|
.build(&event_loop)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
println!("Wa ha ha! You thought that closing the window would finish this?!");
|
2019-06-25 02:14:55 +10:00
|
|
|
event_loop.run_return(|event, _, control_flow| match event {
|
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
|
|
|
..
|
|
|
|
} => *control_flow = ControlFlow::Exit,
|
|
|
|
_ => *control_flow = ControlFlow::Wait,
|
2019-02-06 02:30:33 +11:00
|
|
|
});
|
|
|
|
|
|
|
|
println!("Okay we're done now for real.");
|
|
|
|
}
|
2019-07-26 04:56:24 +10:00
|
|
|
|
2019-09-14 09:09:45 +10:00
|
|
|
#[cfg(any(target_os = "ios", target_os = "android"))]
|
2019-07-26 04:56:24 +10:00
|
|
|
fn main() {
|
|
|
|
println!("This platform doesn't support run_return.");
|
|
|
|
}
|