diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index ec8abd87b..4af190ae0 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -137,6 +137,11 @@ Other Changes: - Fixed GetForegroundDrawList()/GetBackgroundDrawList() per-viewport buffers not being collected when unused for io.ConfigMemoryCompactTimer amount of time. (#9303) - Demo: fixed IMGUI_DEMO_MARKER locations for examples applets. (#9261, #3689) [@pthom] +- Internals: + - ButtonBehavior: fixed internal/low-level ImGuiButtonFlags_PressedOnRelease + (as well as equivalent ImGuiSelectableFlags_SelectOnRelease for Selectable) from + not taking current active id. ImGuiButtonFlags_NoHoldingActiveID allows that. + This was pretty sure only used internally by MenuItem(). - Backends: - DirectX9, OpenGL2, OpenGL3, Metal, SDLGPU3, SDLRenderer2, SDLRenderer3: fixed easy-to-fix issues in code assuming ImTextureID_Invalid is always defined to 0. (#9295, #9310) diff --git a/imgui.h b/imgui.h index 32e4a814d..875f40f8e 100644 --- a/imgui.h +++ b/imgui.h @@ -30,7 +30,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.92.7 WIP" -#define IMGUI_VERSION_NUM 19266 +#define IMGUI_VERSION_NUM 19267 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 diff --git a/imgui_internal.h b/imgui_internal.h index 3dbcfd966..b1ae63f27 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1033,7 +1033,7 @@ enum ImGuiButtonFlagsPrivate_ ImGuiButtonFlags_PressedOnClick = 1 << 4, // return true on click (mouse down event) ImGuiButtonFlags_PressedOnClickRelease = 1 << 5, // [Default] return true on click + release on same item <-- this is what the majority of Button are using ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 6, // return true on click + release even if the release event is not done while hovering the item - ImGuiButtonFlags_PressedOnRelease = 1 << 7, // return true on release (default requires click+release) + ImGuiButtonFlags_PressedOnRelease = 1 << 7, // return true on release (default requires click+release). Prior to 2026/03/20 this implied ImGuiButtonFlags_NoHoldingActiveId but they are separate now. ImGuiButtonFlags_PressedOnDoubleClick = 1 << 8, // return true on double-click (default requires click+release) ImGuiButtonFlags_PressedOnDragDropHold = 1 << 9, // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers) //ImGuiButtonFlags_Repeat = 1 << 10, // hold to repeat -> use ImGuiItemFlags_ButtonRepeat instead. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 117733349..fec9075ac 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -653,6 +653,14 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool FocusWindow(window, ImGuiFocusRequestFlags_RestoreFocusedChild); // Still need to focus and bring to front, but try to avoid losing NavId when navigating a child } } + if (flags & ImGuiButtonFlags_PressedOnRelease) + { + // FIXME: Traditionally ImGuiButtonFlags_PressedOnRelease never took ActiveId. Adding it in 2026-03-20 since ImGuiButtonFlags_NoHoldingActiveId can always be added. + // We don't yet perform an explicit ClearActiveID() to reduce scope of change, but this possibility could be investigated. + if (!(flags & ImGuiButtonFlags_NoHoldingActiveId)) + SetActiveID(id, window); // Hold on ID + g.ActiveIdMouseButton = (ImS8)mouse_button_clicked; + } } if (flags & ImGuiButtonFlags_PressedOnRelease) { @@ -9458,7 +9466,7 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut BeginDisabled(); // We use ImGuiSelectableFlags_NoSetKeyOwner to allow down on one menu item, move, up on another. - const ImGuiSelectableFlags selectable_flags = ImGuiSelectableFlags_SelectOnRelease | ImGuiSelectableFlags_NoSetKeyOwner | ImGuiSelectableFlags_SetNavIdOnHover; + const ImGuiSelectableFlags selectable_flags = ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnRelease | ImGuiSelectableFlags_NoSetKeyOwner | ImGuiSelectableFlags_SetNavIdOnHover; const ImGuiMenuColumns* offsets = &window->DC.MenuColumns; if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) {