|
|
|
@ -9141,16 +9141,10 @@ void ImGui::SetItemKeyOwner(ImGuiKey key, ImGuiInputFlags flags) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags) |
|
|
|
|
// This is equivalent to comparing KeyMods + doing a IsKeyPressed()
|
|
|
|
|
bool ImGui::IsKeyChordPressed(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags) |
|
|
|
|
{ |
|
|
|
|
ImGuiContext& g = *GImGui; |
|
|
|
|
|
|
|
|
|
// When using (owner_id == 0/Any): SetShortcutRouting() will use CurrentFocusScopeId and filter with this, so IsKeyPressed() is fine with he 0/Any.
|
|
|
|
|
if ((flags & ImGuiInputFlags_RouteMask_) == 0) |
|
|
|
|
flags |= ImGuiInputFlags_RouteFocused; |
|
|
|
|
if (!SetShortcutRouting(key_chord, owner_id, flags)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (key_chord & ImGuiMod_Shortcut) |
|
|
|
|
key_chord = ConvertShortcutMod(key_chord); |
|
|
|
|
ImGuiKey mods = (ImGuiKey)(key_chord & ImGuiMod_Mask_); |
|
|
|
@ -9161,11 +9155,22 @@ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags |
|
|
|
|
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_); |
|
|
|
|
if (key == ImGuiKey_None) |
|
|
|
|
key = ConvertSingleModFlagToKey(&g, mods); |
|
|
|
|
|
|
|
|
|
if (!IsKeyPressed(key, owner_id, (flags & (ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateMask_)))) |
|
|
|
|
return false; |
|
|
|
|
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedByShortcut) == 0); // Passing flags not supported by this function!
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags) |
|
|
|
|
{ |
|
|
|
|
// When using (owner_id == 0/Any): SetShortcutRouting() will use CurrentFocusScopeId and filter with this, so IsKeyPressed() is fine with he 0/Any.
|
|
|
|
|
if ((flags & ImGuiInputFlags_RouteMask_) == 0) |
|
|
|
|
flags |= ImGuiInputFlags_RouteFocused; |
|
|
|
|
if (!SetShortcutRouting(key_chord, owner_id, flags)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (!IsKeyChordPressed(key_chord, owner_id, flags)) |
|
|
|
|
return false; |
|
|
|
|
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedByShortcut) == 0); // Passing flags not supported by this function!
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|