mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-05 04:28:47 +02:00
Disabled: disabled items set HoveredId, allowing e.g. HoveredIdTimer to function. (#211, #3419) + Menus: fix hovering a disabled menu or menu item not closing other menus.
Rework of https://github.com/rokups/imgui/commit/c24b470
Note that the declared intent of that commit "Prevents window from being dragged if mouse hovers a disabled item." was already fullfilled by a876ad87
.
Changes in ButtonBehavior() not needed anymore since ImGuiButtonFlags_Disabled is gone
This commit is contained in:
12
imgui.cpp
12
imgui.cpp
@ -3216,7 +3216,7 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
|
||||
return false;
|
||||
if (g.NavDisableMouseHover)
|
||||
return false;
|
||||
if (!IsWindowContentHoverable(window, ImGuiHoveredFlags_None) || (g.CurrentItemFlags & ImGuiItemFlags_Disabled))
|
||||
if (!IsWindowContentHoverable(window, ImGuiHoveredFlags_None))
|
||||
{
|
||||
g.HoveredIdDisabled = true;
|
||||
return false;
|
||||
@ -3225,9 +3225,17 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
|
||||
// We exceptionally allow this function to be called with id==0 to allow using it for easy high-level
|
||||
// hover test in widgets code. We could also decide to split this function is two.
|
||||
if (id != 0)
|
||||
{
|
||||
SetHoveredID(id);
|
||||
|
||||
// When disabled we'll return false but still set HoveredId
|
||||
if (g.CurrentItemFlags & ImGuiItemFlags_Disabled)
|
||||
{
|
||||
g.HoveredIdDisabled = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id != 0)
|
||||
{
|
||||
// [DEBUG] Item Picker tool!
|
||||
// We perform the check here because SetHoveredID() is not frequently called (1~ time a frame), making
|
||||
// the cost of this tool near-zero. We can get slightly better call-stack and support picking non-hovered
|
||||
|
Reference in New Issue
Block a user