diff --git a/imgui-sdl2-support/src/lib.rs b/imgui-sdl2-support/src/lib.rs index eaee2d2..b51c1ef 100644 --- a/imgui-sdl2-support/src/lib.rs +++ b/imgui-sdl2-support/src/lib.rs @@ -143,10 +143,10 @@ fn handle_key(io: &mut Io, key: &Scancode, pressed: bool) { /// Handle changes in the key modifier states. fn handle_key_modifier(io: &mut Io, keymod: &Mod) { - io.key_shift = keymod.intersects(Mod::LSHIFTMOD | Mod::RSHIFTMOD); - io.key_ctrl = keymod.intersects(Mod::LCTRLMOD | Mod::RCTRLMOD); - io.key_alt = keymod.intersects(Mod::LALTMOD | Mod::RALTMOD); - io.key_super = keymod.intersects(Mod::LGUIMOD | Mod::RGUIMOD); + io.add_key_event(Key::ModShift, keymod.intersects(Mod::LSHIFTMOD | Mod::RSHIFTMOD)); + io.add_key_event(Key::ModCtrl, keymod.intersects(Mod::LCTRLMOD | Mod::RCTRLMOD)); + io.add_key_event(Key::ModAlt, keymod.intersects(Mod::LALTMOD | Mod::RALTMOD)); + io.add_key_event(Key::ModSuper, keymod.intersects(Mod::LGUIMOD | Mod::RGUIMOD)); } /// Map an imgui::MouseCursor to an equivalent sdl2::mouse::SystemCursor. diff --git a/imgui-winit-support/src/lib.rs b/imgui-winit-support/src/lib.rs index 8b3dbee..9bf3ef5 100644 --- a/imgui-winit-support/src/lib.rs +++ b/imgui-winit-support/src/lib.rs @@ -399,10 +399,10 @@ impl WinitPlatform { // 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.key_shift = modifiers.shift(); - io.key_ctrl = modifiers.ctrl(); - io.key_alt = modifiers.alt(); - io.key_super = modifiers.logo(); + 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); diff --git a/imgui/src/input/keyboard.rs b/imgui/src/input/keyboard.rs index 9a2ccb1..0860595 100644 --- a/imgui/src/input/keyboard.rs +++ b/imgui/src/input/keyboard.rs @@ -147,6 +147,11 @@ pub enum Key { ReservedForModShift = sys::ImGuiKey_ReservedForModShift, ReservedForModAlt = sys::ImGuiKey_ReservedForModAlt, ReservedForModSuper = sys::ImGuiKey_ReservedForModSuper, + ModCtrl = sys::ImGuiMod_Ctrl, + ModShift = sys::ImGuiMod_Shift, + ModAlt = sys::ImGuiMod_Alt, + ModSuper = sys::ImGuiMod_Super, + ModShortcut = sys::ImGuiMod_Shortcut, } impl Key {