diff --git a/imgui.cpp b/imgui.cpp index 08195ca08..bbf803525 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1824,7 +1824,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL) ImGuiContext& g = *GImGui; g.ActiveIdIsJustActivated = (g.ActiveId != id); g.ActiveId = id; - g.ActiveIdAllowNavMove = false; + g.ActiveIdAllowNavDirFlags = 0; g.ActiveIdAllowOverlap = false; g.ActiveIdWindow = window; if (id) @@ -1847,7 +1847,7 @@ void ImGui::SetActiveIDNoNav(ImGuiID id, ImGuiWindow* window) ImGuiContext& g = *GImGui; g.ActiveIdIsJustActivated = (g.ActiveId != id); g.ActiveId = id; - g.ActiveIdAllowNavMove = false; + g.ActiveIdAllowNavDirFlags = 0; g.ActiveIdAllowOverlap = false; g.ActiveIdWindow = window; g.ActiveIdSource = (g.NavActivateId == id || g.NavInputId == id) ? ImGuiInputSource_Nav : ImGuiInputSource_Mouse; @@ -2511,13 +2511,14 @@ static void NavUpdate() g.NavMoveRequest = false; // Initiate directional inputs request + const int allowed_dir_flags = (g.ActiveId == 0) ? ~0 : g.ActiveIdAllowNavDirFlags; g.NavMoveDir = ImGuiNavDir_None; - if (g.FocusedWindow && !g.NavWindowingTarget && (g.ActiveId == 0 || g.ActiveIdAllowNavMove) && !(g.FocusedWindow->Flags & ImGuiWindowFlags_NoNav)) + if (g.FocusedWindow && !g.NavWindowingTarget && allowed_dir_flags && !(g.FocusedWindow->Flags & ImGuiWindowFlags_NoNav)) { - if (IsKeyPressedMap(ImGuiKey_NavLeft, true)) g.NavMoveDir = ImGuiNavDir_Left; - if (IsKeyPressedMap(ImGuiKey_NavRight, true)) g.NavMoveDir = ImGuiNavDir_Right; - if (IsKeyPressedMap(ImGuiKey_NavUp, true)) g.NavMoveDir = ImGuiNavDir_Up; - if (IsKeyPressedMap(ImGuiKey_NavDown, true)) g.NavMoveDir = ImGuiNavDir_Down; + if ((allowed_dir_flags & (1<