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));