Skip to content

Commit

Permalink
Fixes for 1.89.7 + new ImGuiButtonFlags_AllowOverlap behavior handled…
Browse files Browse the repository at this point in the history
… by ButtonBehavior() fixes other items from hovering while dragging plot.
  • Loading branch information
ocornut committed Jun 28, 2023
1 parent 6dd8007 commit cc5e1da
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions implot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ You can read releases logs https://github.com/epezent/implot/releases for more d
#define ImDrawFlags_RoundCornersAll ImDrawCornerFlags_All
#endif

// Support for pre-1.89.7 versions.
#if (IMGUI_VERSION_NUM < 18966)
#define ImGuiButtonFlags_AllowOverlap ImGuiButtonFlags_AllowItemOverlap
#endif

// Visual Studio warnings
#ifdef _MSC_VER
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
Expand Down Expand Up @@ -1808,7 +1813,7 @@ bool UpdateInput(ImPlotPlot& plot) {

// BUTTON STATE -----------------------------------------------------------

const ImGuiButtonFlags plot_button_flags = ImGuiButtonFlags_AllowItemOverlap
const ImGuiButtonFlags plot_button_flags = ImGuiButtonFlags_AllowOverlap
| ImGuiButtonFlags_PressedOnClick
| ImGuiButtonFlags_PressedOnDoubleClick
| ImGuiButtonFlags_MouseButtonLeft
Expand All @@ -1818,7 +1823,9 @@ bool UpdateInput(ImPlotPlot& plot) {
| plot_button_flags;

const bool plot_clicked = ImGui::ButtonBehavior(plot.PlotRect,plot.ID,&plot.Hovered,&plot.Held,plot_button_flags);
ImGui::SetItemAllowOverlap();
#if (IMGUI_VERSION_NUM < 18966)
ImGui::SetItemAllowOverlap(); // Handled by ButtonBehavior()
#endif

if (plot_clicked) {
if (!ImHasFlag(plot.Flags, ImPlotFlags_NoBoxSelect) && IO.MouseClicked[gp.InputMap.Select] && ImHasFlag(IO.KeyMods, gp.InputMap.SelectMod)) {
Expand Down

0 comments on commit cc5e1da

Please sign in to comment.