diff --git a/imgui.cpp b/imgui.cpp index 6fcbc85d..447f78a1 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2630,7 +2630,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg) window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None; #ifdef IMGUI_ENABLE_TEST_ENGINE - ImGuiTestEngineHook_ItemAdd(id, bb); + ImGuiTestEngineHook_ItemAdd(bb, id); #endif // Clipping test diff --git a/imgui_internal.h b/imgui_internal.h index 033888ef..ab0691d1 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1427,7 +1427,7 @@ IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned ch #ifdef IMGUI_ENABLE_TEST_ENGINE extern void ImGuiTestEngineHook_PreNewFrame(); extern void ImGuiTestEngineHook_PostNewFrame(); -extern void ImGuiTestEngineHook_ItemAdd(ImGuiID id, const ImRect& bb); +extern void ImGuiTestEngineHook_ItemAdd(const ImRect& bb, ImGuiID id); extern void ImGuiTestEngineHook_ItemInfo(ImGuiID id, const char* label, int flags); #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) ImGuiTestEngineHook_ItemInfo(_ID, _LABEL, _FLAGS) // Register status flags #else diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 672fa5ca..3bc83441 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -396,6 +396,11 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool if ((flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window) g.HoveredWindow = window; +#ifdef IMGUI_ENABLE_TEST_ENGINE + if (window->DC.LastItemId != id) + ImGuiTestEngineHook_ItemAdd(bb, id); +#endif + bool pressed = false; bool hovered = ItemHoverable(bb, id);