Buttons: using ImGuiItemFlags_ButtonRepeat makes default button behavior use PressedOnClick instead of PressedOnClickRelease when unspecified.

This commit is contained in:
ocornut 2024-10-29 14:26:02 +01:00
parent 0bde57c25a
commit 9a0dff1bc5
3 changed files with 10 additions and 8 deletions

View File

@ -45,6 +45,8 @@ Other changes:
- Selectable: selected Selectables use ImGuiCol_Header instead of an arbitrary lerp - Selectable: selected Selectables use ImGuiCol_Header instead of an arbitrary lerp
between _Header and _HeaderHovered which was introduced v1.91 (#8106, #1861) between _Header and _HeaderHovered which was introduced v1.91 (#8106, #1861)
- Buttons: using ImGuiItemFlags_ButtonRepeat makes default button behavior use
PressedOnClick instead of PressedOnClickRelease when unspecified.
- Fonts: removed const qualifiers from most font functions. - Fonts: removed const qualifiers from most font functions.
- Backends: DX12: Unmap() call specify written range. The range is informational and - Backends: DX12: Unmap() call specify written range. The range is informational and
may be used by debug tools. may be used by debug tools.

View File

@ -29,7 +29,7 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.91.5 WIP" #define IMGUI_VERSION "1.91.5 WIP"
#define IMGUI_VERSION_NUM 19141 #define IMGUI_VERSION_NUM 19142
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
/* /*

View File

@ -495,19 +495,19 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
// Default behavior inherited from item flags
// Note that _both_ ButtonFlags and ItemFlags are valid sources, so copy one into the item_flags and only check that.
ImGuiItemFlags item_flags = (g.LastItemData.ID == id ? g.LastItemData.ItemFlags : g.CurrentItemFlags);
if (flags & ImGuiButtonFlags_AllowOverlap)
item_flags |= ImGuiItemFlags_AllowOverlap;
// Default only reacts to left mouse button // Default only reacts to left mouse button
if ((flags & ImGuiButtonFlags_MouseButtonMask_) == 0) if ((flags & ImGuiButtonFlags_MouseButtonMask_) == 0)
flags |= ImGuiButtonFlags_MouseButtonLeft; flags |= ImGuiButtonFlags_MouseButtonLeft;
// Default behavior requires click + release inside bounding box // Default behavior requires click + release inside bounding box
if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0) if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0)
flags |= ImGuiButtonFlags_PressedOnDefault_; flags |= (item_flags & ImGuiItemFlags_ButtonRepeat) ? ImGuiButtonFlags_PressedOnClick : ImGuiButtonFlags_PressedOnDefault_;
// Default behavior inherited from item flags
// Note that _both_ ButtonFlags and ItemFlags are valid sources, so copy one into the item_flags and only check that.
ImGuiItemFlags item_flags = (g.LastItemData.ID == id ? g.LastItemData.ItemFlags : g.CurrentItemFlags);
if (flags & ImGuiButtonFlags_AllowOverlap)
item_flags |= ImGuiItemFlags_AllowOverlap;
ImGuiWindow* backup_hovered_window = g.HoveredWindow; ImGuiWindow* backup_hovered_window = g.HoveredWindow;
const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredWindow && g.HoveredWindow->RootWindow == window; const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredWindow && g.HoveredWindow->RootWindow == window;