epezent / implot

Immediate Mode Plotting
MIT License
4.55k stars 503 forks source link

IsSubplotsHovered() issue with current ImGui (Ver 1.89.7) #503

Closed adamsepp closed 11 months ago

adamsepp commented 11 months ago

Hello,

ImPlot Version: v0.14 ImPlot Branch: Main ImGui Version: v1.89 WIP ImGui Branch: Docking Operating System: Win10 / Win11

After updating ImGui to the latest version the IsSubplotsHovered() is slightly differnt now. After clicking on a SubPlot the IsSubplotsHovered() is returning false for ~5 frames, even if the mouse is still in the chart area. (Before the IsSubplotsHovered() was not influenced by mouse click...)

If I'm not wrong, the reason is that since the ImGui change "2023/06/28 (1.89.7) - overlapping items:..." now the mouse click set the g.ActiveId for this subplot...

So I think the SubPlot need to use the ImGuiHoveredFlags_AllowWhenBlockedByActiveItem flag now? Then this line: subplot.FrameHovered = subplot.FrameRect.Contains(ImGui::GetMousePos()) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows);

will be changed to this: subplot.FrameHovered = subplot.FrameRect.Contains(ImGui::GetMousePos()) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem);

Background of this problem: I have 2 or more subplots on which I usually put tooltips (Subplots are linked). I store the current tooltip by clicking and then hover to another position to compare the current one and the stored one... This is very helpful to analize data quickly. When leaving the chart, I delete the stored tooltip... (<- this problem always deleted now my tooltip right away, so I had to change it)

Working example: https://github.com/epezent/implot/assets/107212703/18f7bca8-2b6c-4c9c-ad9e-139d7bcdc135

IsSubplotsHovered() not working: https://github.com/epezent/implot/assets/107212703/05b542e1-9b72-4a6a-ae61-3a2220fed78c

Is it possible to make this fix also in the repository?

epezent commented 11 months ago

https://github.com/epezent/implot/commit/1ff4b45819a20b6725a264b9afe9390566a6a6ee

adamsepp commented 11 months ago

Thank you! :-)