mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
e2c84725de
* Format everything and add rustfmt to travis * Remove extern crate winit from examples and add force_multiline_blocks * Format the code properly * Fix inconsistent period in PULL_REQUEST_TEMPLATE.md * Only run rustfmt on nightly * Travis fixings
45 lines
1.4 KiB
Rust
45 lines
1.4 KiB
Rust
use winit::{
|
|
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
|
|
event_loop::{ControlFlow, EventLoop},
|
|
window::WindowBuilder,
|
|
};
|
|
|
|
fn main() {
|
|
let event_loop = EventLoop::new();
|
|
|
|
let mut resizable = false;
|
|
|
|
let window = WindowBuilder::new()
|
|
.with_title("Hit space to toggle resizability.")
|
|
.with_inner_size((400, 200).into())
|
|
.with_resizable(resizable)
|
|
.build(&event_loop)
|
|
.unwrap();
|
|
|
|
event_loop.run(move |event, _, control_flow| {
|
|
*control_flow = ControlFlow::Wait;
|
|
match event {
|
|
Event::WindowEvent { event, .. } => {
|
|
match event {
|
|
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
|
|
WindowEvent::KeyboardInput {
|
|
input:
|
|
KeyboardInput {
|
|
virtual_keycode: Some(VirtualKeyCode::Space),
|
|
state: ElementState::Released,
|
|
..
|
|
},
|
|
..
|
|
} => {
|
|
resizable = !resizable;
|
|
println!("Resizable: {}", resizable);
|
|
window.set_resizable(resizable);
|
|
},
|
|
_ => (),
|
|
}
|
|
},
|
|
_ => (),
|
|
};
|
|
});
|
|
}
|