@@ -9141,16 +9141,10 @@ void ImGui::SetItemKeyOwner(ImGuiKey key, ImGuiInputFlags flags)
9141
9141
}
9142
9142
}
9143
9143
9144
- bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags)
9144
+ // This is equivalent to comparing KeyMods + doing a IsKeyPressed()
9145
+ bool ImGui::IsKeyChordPressed(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags)
9145
9146
{
9146
9147
ImGuiContext& g = *GImGui;
9147
-
9148
- // When using (owner_id == 0/Any): SetShortcutRouting() will use CurrentFocusScopeId and filter with this, so IsKeyPressed() is fine with he 0/Any.
9149
- if ((flags & ImGuiInputFlags_RouteMask_) == 0)
9150
- flags |= ImGuiInputFlags_RouteFocused;
9151
- if (!SetShortcutRouting(key_chord, owner_id, flags))
9152
- return false;
9153
-
9154
9148
if (key_chord & ImGuiMod_Shortcut)
9155
9149
key_chord = ConvertShortcutMod(key_chord);
9156
9150
ImGuiKey mods = (ImGuiKey)(key_chord & ImGuiMod_Mask_);
@@ -9161,11 +9155,22 @@ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags
9161
9155
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
9162
9156
if (key == ImGuiKey_None)
9163
9157
key = ConvertSingleModFlagToKey(&g, mods);
9164
-
9165
9158
if (!IsKeyPressed(key, owner_id, (flags & (ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateMask_))))
9166
9159
return false;
9167
- IM_ASSERT((flags & ~ImGuiInputFlags_SupportedByShortcut) == 0); // Passing flags not supported by this function!
9160
+ return true;
9161
+ }
9168
9162
9163
+ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags)
9164
+ {
9165
+ // When using (owner_id == 0/Any): SetShortcutRouting() will use CurrentFocusScopeId and filter with this, so IsKeyPressed() is fine with he 0/Any.
9166
+ if ((flags & ImGuiInputFlags_RouteMask_) == 0)
9167
+ flags |= ImGuiInputFlags_RouteFocused;
9168
+ if (!SetShortcutRouting(key_chord, owner_id, flags))
9169
+ return false;
9170
+
9171
+ if (!IsKeyChordPressed(key_chord, owner_id, flags))
9172
+ return false;
9173
+ IM_ASSERT((flags & ~ImGuiInputFlags_SupportedByShortcut) == 0); // Passing flags not supported by this function!
9169
9174
return true;
9170
9175
}
9171
9176
0 commit comments