From 9176eedf24070649db23ea59d4174bcf6281b640 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 24 Jan 2024 17:47:30 +0100 Subject: [PATCH] Internals: SetShortcutRouting() move code so next commit is easier to read. Should be no-op. --- imgui.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 4cb27b55..8177e104 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8438,17 +8438,20 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI return true; } - // Specific culling for shortcuts with no modifiers when there's an active id. - // e.g. Shortcut(ImGuiKey_G) also generates 'g' character, should not trigger when InputText() is active. - // but Shortcut(Ctrl+G) should generally trigger when InputText() is active. - // TL;DR: lettered shortcut with no mods or with only Alt mod will not trigger while an item reading text input is active. - // (We cannot filter based on io.InputQueueCharacters[] contents because of trickling and key<>chars submission order are undefined) - if ((flags & ImGuiInputFlags_RouteFocused) && (g.ActiveId != 0 && g.ActiveId != owner_id)) - if (g.IO.WantTextInput && IsKeyChordPotentiallyCharInput(key_chord)) + // Specific culling when there's an active. + if (g.ActiveId != 0 && g.ActiveId != owner_id) + { + // Cull shortcuts with no modifiers when it could generate a character. + // e.g. Shortcut(ImGuiKey_G) also generates 'g' character, should not trigger when InputText() is active. + // but Shortcut(Ctrl+G) should generally trigger when InputText() is active. + // TL;DR: lettered shortcut with no mods or with only Alt mod will not trigger while an item reading text input is active. + // (We cannot filter based on io.InputQueueCharacters[] contents because of trickling and key<>chars submission order are undefined) + if ((flags & ImGuiInputFlags_RouteFocused) && g.IO.WantTextInput && IsKeyChordPotentiallyCharInput(key_chord)) { IMGUI_DEBUG_LOG_INPUTROUTING("SetShortcutRouting(%s, owner_id=0x%08X, flags=%04X) -> filtered as potential char input\n", GetKeyChordName(key_chord), owner_id, flags); return false; } + } // FIXME-SHORTCUT: A way to configure the location/focus-scope to test would render this more flexible. const int score = CalcRoutingScore(g.CurrentFocusScopeId, owner_id, flags);