mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-24 20:08:31 +00:00
Merge pull request #701 from rodrigorc/FixWinitKeyboard
Fix keyboard modifiers in Winit with the new ImGui version.
This commit is contained in:
commit
93cde6aa4a
@ -143,10 +143,22 @@ fn handle_key(io: &mut Io, key: &Scancode, pressed: bool) {
|
|||||||
|
|
||||||
/// Handle changes in the key modifier states.
|
/// Handle changes in the key modifier states.
|
||||||
fn handle_key_modifier(io: &mut Io, keymod: &Mod) {
|
fn handle_key_modifier(io: &mut Io, keymod: &Mod) {
|
||||||
io.key_shift = keymod.intersects(Mod::LSHIFTMOD | Mod::RSHIFTMOD);
|
io.add_key_event(
|
||||||
io.key_ctrl = keymod.intersects(Mod::LCTRLMOD | Mod::RCTRLMOD);
|
imgui::Key::ModShift,
|
||||||
io.key_alt = keymod.intersects(Mod::LALTMOD | Mod::RALTMOD);
|
keymod.intersects(Mod::LSHIFTMOD | Mod::RSHIFTMOD),
|
||||||
io.key_super = keymod.intersects(Mod::LGUIMOD | Mod::RGUIMOD);
|
);
|
||||||
|
io.add_key_event(
|
||||||
|
imgui::Key::ModCtrl,
|
||||||
|
keymod.intersects(Mod::LCTRLMOD | Mod::RCTRLMOD),
|
||||||
|
);
|
||||||
|
io.add_key_event(
|
||||||
|
imgui::Key::ModAlt,
|
||||||
|
keymod.intersects(Mod::LALTMOD | Mod::RALTMOD),
|
||||||
|
);
|
||||||
|
io.add_key_event(
|
||||||
|
imgui::Key::ModSuper,
|
||||||
|
keymod.intersects(Mod::LGUIMOD | Mod::RGUIMOD),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Map an imgui::MouseCursor to an equivalent sdl2::mouse::SystemCursor.
|
/// Map an imgui::MouseCursor to an equivalent sdl2::mouse::SystemCursor.
|
||||||
|
|||||||
@ -399,10 +399,10 @@ impl WinitPlatform {
|
|||||||
// not reliably send modifier states during certain events like ScreenCapture.
|
// not reliably send modifier states during certain events like ScreenCapture.
|
||||||
// Gotta let the people show off their pretty imgui widgets!
|
// Gotta let the people show off their pretty imgui widgets!
|
||||||
if let WindowEvent::ModifiersChanged(modifiers) = event {
|
if let WindowEvent::ModifiersChanged(modifiers) = event {
|
||||||
io.key_shift = modifiers.shift();
|
io.add_key_event(Key::ModShift, modifiers.shift());
|
||||||
io.key_ctrl = modifiers.ctrl();
|
io.add_key_event(Key::ModCtrl, modifiers.ctrl());
|
||||||
io.key_alt = modifiers.alt();
|
io.add_key_event(Key::ModAlt, modifiers.alt());
|
||||||
io.key_super = modifiers.logo();
|
io.add_key_event(Key::ModSuper, modifiers.logo());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.handle_window_event(io, window, event);
|
self.handle_window_event(io, window, event);
|
||||||
|
|||||||
@ -147,6 +147,11 @@ pub enum Key {
|
|||||||
ReservedForModShift = sys::ImGuiKey_ReservedForModShift,
|
ReservedForModShift = sys::ImGuiKey_ReservedForModShift,
|
||||||
ReservedForModAlt = sys::ImGuiKey_ReservedForModAlt,
|
ReservedForModAlt = sys::ImGuiKey_ReservedForModAlt,
|
||||||
ReservedForModSuper = sys::ImGuiKey_ReservedForModSuper,
|
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 {
|
impl Key {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user