Fix backspace handling

On macOS at least, backspace triggers a character input event as well as
key down/release -- the key_* handlers trigger as well as
doCommandBySelector. We're not interested in backspace as an input
character though. More generally, let's exclude control characters. This
could be extended in the future to more categories.
This commit is contained in:
Simon Hausmann 2020-09-15 21:46:30 +02:00
parent 0d751e6627
commit 6bcbf082ff

View file

@ -371,17 +371,19 @@ impl EventLoop {
ref window_id, ref window_id,
event: winit::event::WindowEvent::ReceivedCharacter(ch), event: winit::event::WindowEvent::ReceivedCharacter(ch),
} => { } => {
crate::animations::update_animations(); if !ch.is_control() {
ALL_WINDOWS.with(|windows| { crate::animations::update_animations();
if let Some(Some(window)) = ALL_WINDOWS.with(|windows| {
windows.borrow().get(&window_id).map(|weakref| weakref.upgrade()) if let Some(Some(window)) =
{ windows.borrow().get(&window_id).map(|weakref| weakref.upgrade())
let key_event = KeyEvent::CharacterInput(ch.into()); {
window.clone().process_key_input(&key_event, component); let key_event = KeyEvent::CharacterInput(ch.into());
// FIXME: remove this, it should be based on actual changes rather than this window.clone().process_key_input(&key_event, component);
window.request_redraw(); // FIXME: remove this, it should be based on actual changes rather than this
} window.request_redraw();
}); }
});
}
} }
_ => (), _ => (),