Nav: Fixed SetItemDefaultFocus from stealing default focus when we are initializing default focus for a menu bar layer (#787)

This commit is contained in:
omar 2017-09-29 00:20:51 +02:00
parent f4398226cc
commit cf308f4039
2 changed files with 2 additions and 2 deletions

View File

@ -4132,7 +4132,7 @@ void ImGui::SetItemAllowOverlap()
void ImGui::SetItemDefaultFocus() void ImGui::SetItemDefaultFocus()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.NavWindow == g.CurrentWindow->RootNavWindow && (g.NavInitDefaultRequest || g.NavInitDefaultResultId != 0)) if (g.NavWindow == g.CurrentWindow->RootNavWindow && (g.NavInitDefaultRequest || g.NavInitDefaultResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent)
{ {
g.NavInitDefaultRequest = false; g.NavInitDefaultRequest = false;
g.NavInitDefaultResultExplicit = true; g.NavInitDefaultResultExplicit = true;

View File

@ -2420,7 +2420,7 @@ struct ExampleAppConsole
// Demonstrate keeping focus on the input box // Demonstrate keeping focus on the input box
ImGui::SetItemDefaultFocus(); ImGui::SetItemDefaultFocus();
if (ImGui::IsItemHovered() || reclaim_focus) if (reclaim_focus) //|| ImGui::IsItemHovered())
ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget
ImGui::End(); ImGui::End();