ButtonBehavior, Selectable: made low-level ImGuiButtonFlags_PressedOnRelease not explicitely avoid taking current active id. ImGuiButtonFlags_NoHoldingActiveId may be used for that.

Ditto for ImGuiSelectableFlags_SelectOnRelease, ImGuiSelectableFlags_NoHoldingActiveId. All internals.
Toward #9312
This commit is contained in:
ocornut
2026-03-20 20:05:24 +01:00
parent 4af77622d9
commit 50b488765f
4 changed files with 16 additions and 3 deletions

View File

@@ -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)
{