// 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
@ -4623,9 +4637,10 @@ bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
ImGuiWindow*window=GImGui->CurrentWindow;
ImGuiIDid=str_id?window->GetID(str_id):window->DC.LastItemId;// If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT(id!=0);// However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
IMGUI_APIvoidSetItemDefaultFocus();// FIXME-NAVIGATION // make last item the default focused item of a window
// Utilities
IMGUI_APIboolIsItemHovered();// is the last item hovered by mouse (and usable)? or we are currently using Nav and the item is focused.
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)? or we are currently using Nav and the item is focused.
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_APIboolIsItemFocused();// is the last item focused for keyboard/gamepad navigation?
IMGUI_APIboolIsItemClicked(intmouse_button=0);// is the last item clicked? (e.g. button/node just clicked on)
@ -435,11 +435,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_APIboolIsAnyWindowFocused();
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.
@ -495,21 +494,6 @@ namespace ImGui
IMGUI_APIImGuiContext*GetCurrentContext();
IMGUI_APIvoidSetCurrentContext(ImGuiContext*ctx);
// Obsolete functions (Will be removed! Also see 'API BREAKING CHANGES' section in imgui.cpp)
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
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.
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
ImVec2MousePosPrev;// Previous mouse position temporary storage (nb: not for public use, set to MousePos in NewFrame())
boolMouseClicked[5];// Mouse button went from !Down to Down
ImVec2MouseClickedPos[5];// Position at time of clicking
floatMouseClickedTime[5];// Time of last click (used to figure out double-click)
boolMouseClicked[5];// Mouse button went from !Down to Down
boolMouseDoubleClicked[5];// Has mouse button been double-clicked?
boolMouseReleased[5];// Mouse button went from Down to !Down
boolMouseDownOwned[5];// Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds.
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.
ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
ImGui::Separator();
// NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
// To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here
// would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus.
ImGui::PushID("foo");
ImGui::MenuItem("Menu item","CTRL+M");
if(ImGui::BeginMenu("Menu inside a regular window"))
if(ImGui::TreeNode("Menus inside a regular window"))
{
ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
ImGui::Separator();
// NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
// To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here
// would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus.
ImGui::PushID("foo");
ImGui::MenuItem("Menu item","CTRL+M");
if(ImGui::BeginMenu("Menu inside a regular window"))
// 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)