Nav: Reordered Cancel handling code so you you can leave a child within a popup without closing the popup (#323)

This commit is contained in:
ocornut 2016-08-04 12:53:46 +02:00
parent c263961f07
commit d85c1be6b6

View File

@ -2591,26 +2591,7 @@ static void NavUpdate()
{
ImGui::SetActiveID(0);
}
else if (g.OpenPopupStack.Size > 0)
{
// Close open popup or move back to parent window
ClosePopupToLevel(g.OpenPopupStack.Size - 1);
}
else if (g.NavLayer != 0)
{
g.NavLayer = 0;
if (g.NavWindow->NavLastId)
SetNavIdMoveMouse(g.NavWindow->NavLastId, ImRect());
else
NavInitWindow(g.NavWindow, true);
}
else
{
// Clear NavId for popups but keep it for regular child window so we can leave one and come back where we were
if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
g.NavWindow->NavLastId = 0;
if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && g.NavWindow->ParentWindow)
else if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow)
{
// Exit child window
ImGuiWindow* child_window = g.NavWindow;
@ -2623,12 +2604,28 @@ static void NavUpdate()
if (g.NavDisableMouseHover)
g.NavMousePosDirty = true;
}
else if (g.OpenPopupStack.Size > 0)
{
// Close open popup/menu
ClosePopupToLevel(g.OpenPopupStack.Size - 1);
}
else if (g.NavLayer != 0)
{
// Leave the "menu" layer
g.NavLayer = 0;
if (g.NavWindow->NavLastId)
SetNavIdMoveMouse(g.NavWindow->NavLastId, ImRect());
else
NavInitWindow(g.NavWindow, true);
}
else
{
// Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
g.NavWindow->NavLastId = 0;
g.NavId = 0;
}
}
}
g.NavActivateId = (g.NavId && !g.NavDisableHighlight && !g.NavWindowingTarget && g.ActiveId == 0 && IsNavInputPressed(ImGuiNavInput_PadActivate, ImGuiNavReadMode_Repeat)) ? g.NavId : 0;
g.NavInputId = (g.NavId && !g.NavDisableHighlight && !g.NavWindowingTarget && g.ActiveId == 0 && IsNavInputPressed(ImGuiNavInput_PadInput, ImGuiNavReadMode_Repeat)) ? g.NavId : 0;