Nav: Fixed initial movement (which sends an InitRequest) from clearing NavDisableHighlight and fully enabling Nav feedbacks. (#787)

NB: Setting g.NavInitResultExplicit = false on InitRequest match was added in initial commit c2cb2a6928
This commit is contained in:
omar 2018-01-31 18:53:15 +01:00
parent 47e81a6194
commit e6c0b212e8

View File

@ -2291,7 +2291,7 @@ static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, con
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
{
g.NavInitRequest = g.NavInitResultExplicit = false; // Found a match, clear request
g.NavInitRequest = false; // Found a match, clear request
NavUpdateAnyRequestFlag();
}
if (g.NavInitResultId == 0 || !(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
@ -2887,10 +2887,11 @@ static void ImGui::NavUpdate()
{
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
IM_ASSERT(g.NavWindow);
if (g.NavInitResultExplicit)
SetNavIDAndMoveMouse(g.NavInitResultId, g.NavLayer, g.NavInitResultRectRel);
else
SetNavID(g.NavInitResultId, g.NavLayer);
g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
if (g.NavDisableMouseHover)
g.NavMousePosDirty = true;
}
g.NavInitRequest = false;
g.NavInitResultExplicit = false;