examples/multiwindow.rs: ignore synthetic key press events
@@ -4,7 +4,7 @@ use std::collections::HashMap;
use simple_logger::SimpleLogger;
use winit::{
- event::{ElementState, Event, KeyboardInput, WindowEvent},
+ event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
event_loop::EventLoop,
window::Window,
};
@@ -16,9 +16,12 @@ fn main() {
let mut windows = HashMap::new();
for _ in 0..3 {
let window = Window::new(&event_loop).unwrap();
+ println!("Opened a new window: {:?}", window.id());
windows.insert(window.id(), window);
}
+ println!("Press N to open a new window.");
+
event_loop.run(move |event, event_loop, control_flow| {
control_flow.set_wait();
@@ -39,11 +42,14 @@ fn main() {
input:
KeyboardInput {
state: ElementState::Pressed,
+ virtual_keycode: Some(VirtualKeyCode::N),
..
},
+ is_synthetic: false,
..
} => {
let window = Window::new(event_loop).unwrap();
+ println!("Opened a new window: {:?}", window.id());
windows.insert(window.id(), window);
}
_ => (),
