From dd561e3402156098fb15966acb90d3b7fbbe9f8c Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Sun, 8 Sep 2019 12:08:42 +0300 Subject: [PATCH] Apply backspace fix to winit-20 as well --- imgui-winit-support/src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index 3483a0a..97604a7 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -534,7 +534,13 @@ impl WinitPlatform { _ => (), } } - WindowEvent::ReceivedCharacter(ch) => io.add_input_character(ch), + WindowEvent::ReceivedCharacter(ch) => { + // Exclude the backspace key ('\u{7f}'). Otherwise we will insert this char and then + // delete it. + if ch != '\u{7f}' { + io.add_input_character(ch) + } + } WindowEvent::CursorMoved { position, .. } => { let position = self.scale_pos_from_winit(window, position); io.mouse_pos = [position.x as f32, position.y as f32]; @@ -567,7 +573,7 @@ impl WinitPlatform { MouseButton::Left => io.mouse_down[0] = pressed, MouseButton::Right => io.mouse_down[1] = pressed, MouseButton::Middle => io.mouse_down[2] = pressed, - MouseButton::Other(idx @ 0...4) => io.mouse_down[idx as usize] = pressed, + MouseButton::Other(idx @ 0..=4) => io.mouse_down[idx as usize] = pressed, _ => (), } }