mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 05:19:02 +08:00
Inputs: fixed using Shortcut() or SetNextItemShortcut() within a disabled block bypassing the disabled state. (#7726)
This commit is contained in:
parent
dbffb702f8
commit
fbb903e158
@ -67,6 +67,8 @@ Other changes:
|
|||||||
on third-party backends to set ImGuiBackendFlags_HasMouseCursors and honor changes of
|
on third-party backends to set ImGuiBackendFlags_HasMouseCursors and honor changes of
|
||||||
ImGui::GetMouseCursor() value. (#1495)
|
ImGui::GetMouseCursor() value. (#1495)
|
||||||
- IO: Added io.ClearInputMouse() to clear mouse state. (#4921)
|
- IO: Added io.ClearInputMouse() to clear mouse state. (#4921)
|
||||||
|
- Inputs: fixed using Shortcut() or SetNextItemShortcut() within a disabled block bypassing
|
||||||
|
the disabled state. (#7726)
|
||||||
- TabBar, Style: added ImGuiTabBarFlags_DrawSelectedOverline option to draw an horizontal
|
- TabBar, Style: added ImGuiTabBarFlags_DrawSelectedOverline option to draw an horizontal
|
||||||
line over selected tabs to increase visibility. This is used by docking.
|
line over selected tabs to increase visibility. This is used by docking.
|
||||||
Added corresponding ImGuiCol_TabSelectedOverline and ImGuiCol_TabDimmedSelectedOverline colors.
|
Added corresponding ImGuiCol_TabSelectedOverline and ImGuiCol_TabDimmedSelectedOverline colors.
|
||||||
|
@ -4214,6 +4214,7 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display shortcut (only works with mouse)
|
// Display shortcut (only works with mouse)
|
||||||
|
// (ImGuiItemStatusFlags_HasShortcut in LastItemData denotes we want a tooltip)
|
||||||
if (id == g.LastItemData.ID && (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasShortcut))
|
if (id == g.LastItemData.ID && (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasShortcut))
|
||||||
if (IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_DelayNormal))
|
if (IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_DelayNormal))
|
||||||
SetTooltip("%s", GetKeyChordName(g.LastItemData.Shortcut));
|
SetTooltip("%s", GetKeyChordName(g.LastItemData.Shortcut));
|
||||||
@ -9793,12 +9794,15 @@ void ImGui::SetNextItemShortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags)
|
|||||||
g.NextItemData.ShortcutFlags = flags;
|
g.NextItemData.ShortcutFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called from within ItemAdd: at this point we can read from NextItemData and write to LastItemData
|
||||||
void ImGui::ItemHandleShortcut(ImGuiID id)
|
void ImGui::ItemHandleShortcut(ImGuiID id)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiInputFlags flags = g.NextItemData.ShortcutFlags;
|
ImGuiInputFlags flags = g.NextItemData.ShortcutFlags;
|
||||||
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetNextItemShortcut) == 0); // Passing flags not supported by SetNextItemShortcut()!
|
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetNextItemShortcut) == 0); // Passing flags not supported by SetNextItemShortcut()!
|
||||||
|
|
||||||
|
if (g.LastItemData.InFlags & ImGuiItemFlags_Disabled)
|
||||||
|
return;
|
||||||
if (flags & ImGuiInputFlags_Tooltip)
|
if (flags & ImGuiInputFlags_Tooltip)
|
||||||
{
|
{
|
||||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasShortcut;
|
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasShortcut;
|
||||||
@ -9822,7 +9826,7 @@ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags)
|
|||||||
|
|
||||||
bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID owner_id)
|
bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID owner_id)
|
||||||
{
|
{
|
||||||
//ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
//IMGUI_DEBUG_LOG("Shortcut(%s, flags=%X, owner_id=0x%08X)\n", GetKeyChordName(key_chord, g.TempBuffer.Data, g.TempBuffer.Size), flags, owner_id);
|
//IMGUI_DEBUG_LOG("Shortcut(%s, flags=%X, owner_id=0x%08X)\n", GetKeyChordName(key_chord, g.TempBuffer.Data, g.TempBuffer.Size), flags, owner_id);
|
||||||
|
|
||||||
// When using (owner_id == 0/Any): SetShortcutRouting() will use CurrentFocusScopeId and filter with this, so IsKeyPressed() is fine with he 0/Any.
|
// When using (owner_id == 0/Any): SetShortcutRouting() will use CurrentFocusScopeId and filter with this, so IsKeyPressed() is fine with he 0/Any.
|
||||||
@ -9834,6 +9838,9 @@ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID own
|
|||||||
if (owner_id == ImGuiKeyOwner_Any || owner_id == ImGuiKeyOwner_NoOwner)
|
if (owner_id == ImGuiKeyOwner_Any || owner_id == ImGuiKeyOwner_NoOwner)
|
||||||
owner_id = GetRoutingIdFromOwnerId(owner_id);
|
owner_id = GetRoutingIdFromOwnerId(owner_id);
|
||||||
|
|
||||||
|
if (g.CurrentItemFlags & ImGuiItemFlags_Disabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Submit route
|
// Submit route
|
||||||
if (!SetShortcutRouting(key_chord, flags, owner_id))
|
if (!SetShortcutRouting(key_chord, flags, owner_id))
|
||||||
return false;
|
return false;
|
||||||
|
2
imgui.h
2
imgui.h
@ -28,7 +28,7 @@
|
|||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.90.9 WIP"
|
#define IMGUI_VERSION "1.90.9 WIP"
|
||||||
#define IMGUI_VERSION_NUM 19083
|
#define IMGUI_VERSION_NUM 19084
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user