mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
examples/multiwindow.rs: ignore synthetic key press events
This commit is contained in:
parent
cb41c58f21
commit
d78a870e66
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, KeyboardInput, WindowEvent},
|
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
|
||||||
event_loop::EventLoop,
|
event_loop::EventLoop,
|
||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
|
@ -16,9 +16,12 @@ fn main() {
|
||||||
let mut windows = HashMap::new();
|
let mut windows = HashMap::new();
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
let window = Window::new(&event_loop).unwrap();
|
let window = Window::new(&event_loop).unwrap();
|
||||||
|
println!("Opened a new window: {:?}", window.id());
|
||||||
windows.insert(window.id(), window);
|
windows.insert(window.id(), window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Press N to open a new window.");
|
||||||
|
|
||||||
event_loop.run(move |event, event_loop, control_flow| {
|
event_loop.run(move |event, event_loop, control_flow| {
|
||||||
control_flow.set_wait();
|
control_flow.set_wait();
|
||||||
|
|
||||||
|
@ -39,11 +42,14 @@ fn main() {
|
||||||
input:
|
input:
|
||||||
KeyboardInput {
|
KeyboardInput {
|
||||||
state: ElementState::Pressed,
|
state: ElementState::Pressed,
|
||||||
|
virtual_keycode: Some(VirtualKeyCode::N),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
|
is_synthetic: false,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let window = Window::new(event_loop).unwrap();
|
let window = Window::new(event_loop).unwrap();
|
||||||
|
println!("Opened a new window: {:?}", window.id());
|
||||||
windows.insert(window.id(), window);
|
windows.insert(window.id(), window);
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
Loading…
Reference in a new issue