Use character codes, not keycodes, for backspace

This commit is contained in:
Richard Feldman 2020-07-18 11:05:29 -04:00
parent 056c3362b5
commit 50f7636f92

View file

@ -131,10 +131,8 @@ fn run_event_loop() -> Result<(), Box<dyn Error>> {
match ch { match ch {
'\u{8}' | '\u{7f}' => { '\u{8}' | '\u{7f}' => {
// In Linux, we get a '\u{8}' when you press backspace, // In Linux, we get a '\u{8}' when you press backspace,
// but in macOS we get '\u{7f}'. In both, we // but in macOS we get '\u{7f}'.
// get a Back keydown event. Therefore, we use the text_state.pop();
// Back keydown event and ignore these, resulting
// in a system that works in both Linux and macOS.
} }
'\u{e000}'..='\u{f8ff}' '\u{e000}'..='\u{f8ff}'
| '\u{f0000}'..='\u{ffffd}' | '\u{f0000}'..='\u{ffffd}'
@ -240,12 +238,6 @@ fn handle_keydown(
} }
match virtual_keycode { match virtual_keycode {
Back => {
// Backspace deletes a character.
// In Linux, we get a Unicode character for backspace events
// (which is handled elsewhere), but on macOS we only get one of these.
text_state.pop();
}
Copy => { Copy => {
todo!("copy"); todo!("copy");
} }