From e43cfeac176fb9d793ad9e79749f443fa144623e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 13 Oct 2021 08:55:00 +0200 Subject: [PATCH] egui-winit: fix AltGr characters on windows/linux (#790) Closes https://github.com/emilk/egui/issues/351 Closes https://github.com/emilk/egui/pull/785 --- egui-winit/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/egui-winit/src/lib.rs b/egui-winit/src/lib.rs index 47cea53d..0e4c9c9a 100644 --- a/egui-winit/src/lib.rs +++ b/egui-winit/src/lib.rs @@ -225,10 +225,12 @@ impl State { } } WindowEvent::ReceivedCharacter(ch) => { - if is_printable_char(*ch) - && !self.egui_input.modifiers.ctrl - && !self.egui_input.modifiers.mac_cmd - { + // On Mac we get here when the user presses Cmd-C (copy), ctrl-W, etc. + // We need to ignore these characters that are side-effects of commands. + let is_mac_cmd = cfg!(target_os = "macos") + && (self.egui_input.modifiers.ctrl || self.egui_input.modifiers.mac_cmd); + + if is_printable_char(*ch) && !is_mac_cmd { self.egui_input .events .push(egui::Event::Text(ch.to_string()));