diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 47d3c67c..b2c6baaa 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -41,8 +41,11 @@ Other Changes: - Clipper: Fixed a regression in 1.86 when not calling clipper.End() and late destructing the clipper instance. High-level languages (Lua,Rust etc.) would typically be affected. (#4822) +- IsItemHovered(): added ImGuiHoveredFlags_NoNavOverride to disable the behavior where the + return value is overriden by focus when gamepad/keyboard navigation is active. - Inputs: Fixed IsMouseClicked() repeat mode rate being half of keyboard repeat rate. - Stack Tool: Added option to copy item path to clipboard. (#4631) +- Misc: Fixed IsAnyItemHovered() returning false when using navigation. - Misc: Added constexpr to ImVec2/ImVec4 inline constructors. (#4995) [@Myriachan] - Misc: binary_to_compressed_c tool: Added -nostatic option. (#5021) [@podsvirov] - ImVector: Fixed erase() with empty range. (#5009) [@thedmd] diff --git a/imgui.cpp b/imgui.cpp index e09be5b1..8cbe97b2 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3474,7 +3474,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; - if (g.NavDisableMouseHover && !g.NavDisableHighlight) + if (g.NavDisableMouseHover && !g.NavDisableHighlight && !(flags & ImGuiHoveredFlags_NoNavOverride)) { if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) return false; @@ -3535,8 +3535,6 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) return false; if (!IsMouseHoveringRect(bb.Min, bb.Max)) return false; - if (g.NavDisableMouseHover) - return false; if (!IsWindowContentHoverable(window, ImGuiHoveredFlags_None)) { g.HoveredIdDisabled = true; @@ -3572,6 +3570,9 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) IM_DEBUG_BREAK(); } + if (g.NavDisableMouseHover) + return false; + return true; } diff --git a/imgui.h b/imgui.h index e38dfd64..1e8f5b7c 100644 --- a/imgui.h +++ b/imgui.h @@ -65,7 +65,7 @@ Index of this file: // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) #define IMGUI_VERSION "1.88 WIP" -#define IMGUI_VERSION_NUM 18706 +#define IMGUI_VERSION_NUM 18707 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_HAS_TABLE @@ -1280,6 +1280,7 @@ enum ImGuiHoveredFlags_ ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 7, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns. ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 8, // IsItemHovered() only: Return true even if the position is obstructed or overlapped by another window ImGuiHoveredFlags_AllowWhenDisabled = 1 << 9, // IsItemHovered() only: Return true even if the item is disabled + ImGuiHoveredFlags_NoNavOverride = 1 << 10, // Disable using gamepad/keyboard navigation state when active, always query mouse. ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped, ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows }; diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 19a34257..21415a74 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -6925,7 +6925,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled) if (!enabled) EndDisabled(); - const bool hovered = (g.HoveredId == id) && enabled; + const bool hovered = (g.HoveredId == id) && enabled && !g.NavDisableMouseHover; if (menuset_is_open) g.NavWindow = backed_nav_window;