mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-18 01:14:19 +00:00
Shortcuts: added ImGuiInputFlags_Tooltip. (#456)
This commit is contained in:
parent
77e4171894
commit
c06e6340cd
5 changed files with 37 additions and 14 deletions
14
imgui.cpp
14
imgui.cpp
|
|
@ -4186,6 +4186,11 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag
|
|||
if (g.HoveredIdPreviousFrame != id)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Display shortcut (only works with mouse)
|
||||
if (id == g.LastItemData.ID && (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasShortcut))
|
||||
if (IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_DelayNormal))
|
||||
SetTooltip("%s", GetKeyChordName(g.LastItemData.Shortcut));
|
||||
}
|
||||
|
||||
// When disabled we'll return false but still set HoveredId
|
||||
|
|
@ -10020,7 +10025,14 @@ void ImGui::ItemHandleShortcut(ImGuiID id)
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiInputFlags flags = g.NextItemData.ShortcutFlags;
|
||||
if (!Shortcut(g.NextItemData.Shortcut, flags, id) || g.NavActivateId != 0)
|
||||
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetNextItemShortcut) == 0); // Passing flags not supported by SetNextItemShortcut()!
|
||||
|
||||
if (flags & ImGuiInputFlags_Tooltip)
|
||||
{
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasShortcut;
|
||||
g.LastItemData.Shortcut = g.NextItemData.Shortcut;
|
||||
}
|
||||
if (!Shortcut(g.NextItemData.Shortcut, flags & ImGuiInputFlags_SupportedByShortcut, id) || g.NavActivateId != 0)
|
||||
return;
|
||||
|
||||
// FIXME: Generalize Activation queue?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue