From 842cd0700b8893c820ad16e30460c607066111e1 Mon Sep 17 00:00:00 2001 From: dbr Date: Wed, 1 Feb 2023 11:10:26 +1030 Subject: [PATCH] Move ModifiersChanged handler No longer needs to be handled outside of the main event match statement --- imgui-winit-support/src/lib.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index 9bf3ef5..caba629 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -395,16 +395,6 @@ impl WinitPlatform { window_id, ref event, } if window_id == window.id() => { - // We need to track modifiers separately because some system like macOS, will - // not reliably send modifier states during certain events like ScreenCapture. - // Gotta let the people show off their pretty imgui widgets! - if let WindowEvent::ModifiersChanged(modifiers) = event { - io.add_key_event(Key::ModShift, modifiers.shift()); - io.add_key_event(Key::ModCtrl, modifiers.ctrl()); - io.add_key_event(Key::ModAlt, modifiers.alt()); - io.add_key_event(Key::ModSuper, modifiers.logo()); - } - self.handle_window_event(io, window, event); } // Track key release events outside our window. If we don't do this, @@ -453,6 +443,15 @@ impl WinitPlatform { let logical_size = self.scale_size_from_winit(window, logical_size); io.display_size = [logical_size.width as f32, logical_size.height as f32]; } + WindowEvent::ModifiersChanged(modifiers) => { + // We need to track modifiers separately because some system like macOS, will + // not reliably send modifier states during certain events like ScreenCapture. + // Gotta let the people show off their pretty imgui widgets! + io.add_key_event(Key::ModShift, modifiers.shift()); + io.add_key_event(Key::ModCtrl, modifiers.ctrl()); + io.add_key_event(Key::ModAlt, modifiers.alt()); + io.add_key_event(Key::ModSuper, modifiers.logo()); + } WindowEvent::KeyboardInput { input: KeyboardInput {