IsItemHovered(), IsWindowHovered(): added flags to enable various and more specific behavior. Will enable improvements for popups/context menus and drag'n drop. (relate ~#439, #1013, #143, #925)
The legacy confusing IsItemRectHovered(), IsWindowRectHovered() can be completely removed now.
Changed IsWindowHovered() behavior with default parameter: it now return false is the window is blocked by a popup.
Demo: Added tests for those two functions.
// This is roughly matching the behavior of internal-facing ItemHoverable()
// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered())
// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
IMGUI_APIboolIsItemHovered();// is the last item hovered by mouse (and usable)?
IMGUI_APIboolIsItemRectHovered();// is the last item hovered by mouse? even if another item is active or window is blocked by popup while we are hovering this
IMGUI_APIboolIsItemHovered(ImGuiHoveredFlagsflags=0);// is the last item hovered by mouse (and usable)?
IMGUI_APIboolIsItemActive();// is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false)
IMGUI_APIboolIsItemClicked(intmouse_button=0);// is the last item clicked? (e.g. button/node just clicked on)
IMGUI_APIboolIsItemVisible();// is the last item visible? (aka not out of sight due to clipping/scrolling.)
@ -426,11 +426,10 @@ namespace ImGui
IMGUI_APIImVec2GetItemRectSize();// "
IMGUI_APIvoidSetItemAllowOverlap();// allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
IMGUI_APIboolIsWindowFocused();// is current window focused
IMGUI_APIboolIsWindowHovered();// is current window hovered and hoverable (not blocked by a popup) (differentiate child windows from each others)
IMGUI_APIboolIsWindowRectHovered();// is current window rectangle hovered, disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup)
IMGUI_APIboolIsWindowHovered(ImGuiHoveredFlagsflags=0);// is current window hovered (and typically: not blocked by a popup/modal)
IMGUI_APIboolIsRootWindowFocused();// is current root window focused (root = top-most parent of a child, otherwise self)
IMGUI_APIboolIsRootWindowOrAnyChildFocused();// is current root window or any of its child (including current window) focused
IMGUI_APIboolIsRootWindowOrAnyChildHovered();// is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup)
IMGUI_APIboolIsRootWindowOrAnyChildHovered(ImGuiHoveredFlagsflags=0);// is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup)
IMGUI_APIboolIsAnyWindowHovered();// is mouse hovering any visible window
IMGUI_APIboolIsRectVisible(constImVec2&size);// test if rectangle (of given size, starting from cursor position) is visible / not clipped.
IMGUI_APIboolIsRectVisible(constImVec2&rect_min,constImVec2&rect_max);// test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
@ -569,6 +568,16 @@ enum ImGuiSelectableFlags_
ImGuiSelectableFlags_AllowDoubleClick=1<<2// Generate press events on double clicks too
};
enumImGuiHoveredFlags_
{
ImGuiHoveredFlags_Default=0,// Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them.
ImGuiHoveredFlags_AllowWhenBlockedByPopup=1<<0,// Return true even if a popup window is normally blocking access to this item/window
//ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 1, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem=1<<2,// Return true even if an active item is blocking access to this item/window
ImGuiHoveredFlags_AllowWhenOverlapped=1<<3,// Return true even if the position is overlapped by another window
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
enumImGuiKey_
{
@ -881,10 +890,10 @@ namespace ImGui
boolBegin(constchar*name,bool*p_open,constImVec2&size_on_first_use,floatbg_alpha_override=-1.0f,ImGuiWindowFlagsflags=0);// OBSOLETE 1.52+. use SetNextWindowSize() instead if you want to set a window size.
staticinlineboolIsPosHoveringAnyWindow(constImVec2&){IM_ASSERT(0);returnfalse;}// OBSOLETE 1.51+. This was partly broken. You probably wanted to use ImGui::GetIO().WantCaptureMouse instead.
// Testing IsItemHovered() function (because BulletText is an item itself and that would affect the output of IsItemHovered, we pass all lines in a single items to shorten the code)