This commit is contained in:
none 2023-01-11 11:28:47 +01:00
parent 3342501c3b
commit a462e83394

View File

@ -1,6 +1,6 @@
use winit::{ use winit::{
event::{Event, WindowEvent}, event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop}, event_loop::EventLoop,
window::WindowBuilder, window::WindowBuilder,
}; };
@ -11,18 +11,26 @@ fn main() {
let ver = option_env!("CARGO_PKG_VERSION").unwrap_or("x.x.x"); let ver = option_env!("CARGO_PKG_VERSION").unwrap_or("x.x.x");
let event_loop = EventLoop::new(); let event_loop = EventLoop::new();
let window = WindowBuilder::new()
WindowBuilder::new()
.with_title(format!("IPass - {ver}")) .with_title(format!("IPass - {ver}"))
.build(&event_loop).expect("Expected to create window"); .build(&event_loop).expect("Expected to create window");
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
control_flow.set_wait();
match event { match event {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
window_id, ..
} if window_id == window.id() => *control_flow = ControlFlow::Exit, } => {
println!("The close button was pressed; stopping");
control_flow.set_exit();
},
Event::RedrawRequested(_) => {
//TODO: redraw application
},
_ => (), _ => (),
} }
}); });