mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 14:21:31 +11:00
39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
extern crate winit;
|
|
|
|
fn main() {
|
|
let mut events_loop = winit::EventsLoop::new();
|
|
|
|
let mut resizable = false;
|
|
|
|
let window = winit::WindowBuilder::new()
|
|
.with_title("Hit space to toggle resizability.")
|
|
.with_dimensions((400, 200).into())
|
|
.with_resizable(resizable)
|
|
.build(&events_loop)
|
|
.unwrap();
|
|
|
|
events_loop.run_forever(|event| {
|
|
match event {
|
|
winit::Event::WindowEvent { event, .. } => match event {
|
|
winit::WindowEvent::CloseRequested => return winit::ControlFlow::Break,
|
|
winit::WindowEvent::KeyboardInput {
|
|
input:
|
|
winit::KeyboardInput {
|
|
virtual_keycode: Some(winit::VirtualKeyCode::Space),
|
|
state: winit::ElementState::Released,
|
|
..
|
|
},
|
|
..
|
|
} => {
|
|
resizable = !resizable;
|
|
println!("Resizable: {}", resizable);
|
|
window.set_resizable(resizable);
|
|
}
|
|
_ => (),
|
|
},
|
|
_ => (),
|
|
};
|
|
winit::ControlFlow::Continue
|
|
});
|
|
}
|