From 2ac10e73b0aea980218a42a390ffd47aaed1abf6 Mon Sep 17 00:00:00 2001 From: Max Thrun Date: Wed, 16 Sep 2020 21:46:33 -0700 Subject: [PATCH] check for HoveredIdPreviousFrame incase there is another widget on top of us added via SetItemAllowOverlap, if the previously hovered id does not match our id set our hover flags to false --- implot.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/implot.cpp b/implot.cpp index 9c57229..b57946a 100644 --- a/implot.cpp +++ b/implot.cpp @@ -1262,11 +1262,13 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons frame_size.y = gp.Style.PlotMinSize.y; gp.BB_Frame = ImRect(Window->DC.CursorPos, Window->DC.CursorPos + frame_size); ImGui::ItemSize(gp.BB_Frame); - if (!ImGui::ItemAdd(gp.BB_Frame, 0, &gp.BB_Frame)) { + if (!ImGui::ItemAdd(gp.BB_Frame, ID, &gp.BB_Frame)) { Reset(GImPlot); return false; } gp.Hov_Frame = ImGui::ItemHoverable(gp.BB_Frame, ID); + if (G.HoveredIdPreviousFrame != 0 && G.HoveredIdPreviousFrame != ID) + gp.Hov_Frame = false; ImGui::RenderFrame(gp.BB_Frame.Min, gp.BB_Frame.Max, GetStyleColorU32(ImPlotCol_FrameBg), true, Style.FrameRounding); // canvas bb @@ -1325,7 +1327,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons // (5) calc plot bb gp.BB_Plot = ImRect(gp.BB_Canvas.Min + ImVec2(pad_left, pad_top), gp.BB_Canvas.Max - ImVec2(pad_right, pad_bot)); - gp.Hov_Plot = gp.BB_Plot.Contains(IO.MousePos); + gp.Hov_Plot = gp.BB_Plot.Contains(IO.MousePos) && gp.Hov_Frame; // x axis region bb and hover const ImRect xAxisRegion_bb(gp.BB_Plot.GetBL(), ImVec2(gp.BB_Plot.Max.x, gp.BB_Frame.Max.y));