Skip to content

Commit

Permalink
Nav: Fixed Selectable() crash introduced earlier today in 43ee5d7 + a…
Browse files Browse the repository at this point in the history
…dded comments/assert (#323)
  • Loading branch information
ocornut committed Aug 21, 2016
1 parent df9bdf3 commit 3883a20
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,7 @@ int ImGui::GetFrameCount()
static void SetNavId(ImGuiID id)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.NavWindow);
g.NavId = id;
if (g.NavLayer == 0)
g.NavWindow->NavLastId = g.NavId;
Expand Down Expand Up @@ -9503,7 +9504,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
selected = false;

// Hovering selectable with mouse updates NavId accordingly so navigation can be resumed with gamepad/keyboard (this doesn't happen on most widgets)
if (hovered && !g.NavDisableMouseHover && (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f))
if (hovered && !g.NavDisableMouseHover && g.NavWindow == window && (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f))
{
g.NavDisableHighlight = true;
SetNavId(id);
Expand Down Expand Up @@ -9756,7 +9757,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentMenuSet == window->GetID("##menus"));
ImGuiWindow* backed_nav_window = g.NavWindow;
if (menuset_is_open)
g.NavWindow = window;
g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent)

ImVec2 popup_pos, pos = window->DC.CursorPos;
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
Expand Down

0 comments on commit 3883a20

Please sign in to comment.