From 8a6d209f68411ebe12c21229494112fbd29ebecf Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 7 Aug 2016 13:34:25 +0200 Subject: [PATCH] Nav: Failed movement request with no current NavId fallback to an InitDefaultRequest so that we always land somewhere on first move (#323) --- imgui.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index bbc27e868..148e7723b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2664,6 +2664,14 @@ static void NavUpdate() if (g.NavMoveDir != ImGuiNavDir_None) g.NavMoveRequest = true; + // If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match + if (g.NavMoveRequest && g.NavId == 0) + { + g.NavInitDefaultRequest = g.NavInitDefaultResultExplicit = true; + g.NavInitDefaultResultId = 0; + g.NavDisableHighlight = false; + } + // Scrolling if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget) {