Nav: Fixed IsItemFocused() from returning false when Nav highlight is hidden because mouse has moved. (#787)

This commit is contained in:
ocornut
2020-11-13 20:59:59 +01:00
parent 8119759329
commit e736039538
4 changed files with 11 additions and 8 deletions

View File

@ -2899,10 +2899,8 @@ void ImGui::GcCompactTransientMiscBuffers()
}
// Free up/compact internal window buffers, we can use this when a window becomes unused.
// This is currently unused by the library, but you may call this yourself for easy GC.
// Not freed:
// - ImGuiWindow, ImGuiWindowSettings, Name
// - StateStorage, ColumnsStorage (may hold useful data)
// - ImGuiWindow, ImGuiWindowSettings, Name, StateStorage, ColumnsStorage (may hold useful data)
// This should have no noticeable visual effect. When the window reappear however, expect new allocation/buffer growth/copy cost.
void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow* window)
{
@ -4642,12 +4640,13 @@ bool ImGui::IsItemDeactivatedAfterEdit()
return IsItemDeactivated() && (g.ActiveIdPreviousFrameHasBeenEditedBefore || (g.ActiveId == 0 && g.ActiveIdHasBeenEditedBefore));
}
// == GetItemID() == GetFocusID()
bool ImGui::IsItemFocused()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (g.NavId == 0 || g.NavDisableHighlight || g.NavId != window->DC.LastItemId)
if (g.NavId != window->DC.LastItemId || g.NavId == 0)
return false;
return true;
}