Is current window hovered and hoverable (e.g. not blocked by a popup/modal)? See ImGuiHoveredFlags_ for options. IMPORTANT: If you are trying to check whether your mouse should be dispatched to Dear ImGui or to your underlying app, you should not use this function! Use the 'io.WantCaptureMouse' boolean for that! Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or
| 9005 | // you should not use this function! Use the 'io.WantCaptureMouse' boolean for that! |
| 9006 | // Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" for details. |
| 9007 | bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) |
| 9008 | { |
| 9009 | ImGuiContext& g = *GImGui; |
| 9010 | IM_ASSERT_USER_ERROR((flags & ~ImGuiHoveredFlags_AllowedMaskForIsWindowHovered) == 0, "Invalid flags for IsWindowHovered()!"); |
| 9011 | |
| 9012 | ImGuiWindow* ref_window = g.HoveredWindow; |
| 9013 | ImGuiWindow* cur_window = g.CurrentWindow; |
| 9014 | if (ref_window == NULL) |
| 9015 | return false; |
| 9016 | |
| 9017 | if ((flags & ImGuiHoveredFlags_AnyWindow) == 0) |
| 9018 | { |
| 9019 | IM_ASSERT(cur_window); // Not inside a Begin()/End() |
| 9020 | const bool popup_hierarchy = (flags & ImGuiHoveredFlags_NoPopupHierarchy) == 0; |
| 9021 | const bool dock_hierarchy = (flags & ImGuiHoveredFlags_DockHierarchy) != 0; |
| 9022 | if (flags & ImGuiHoveredFlags_RootWindow) |
| 9023 | cur_window = GetCombinedRootWindow(cur_window, popup_hierarchy, dock_hierarchy); |
| 9024 | |
| 9025 | bool result; |
| 9026 | if (flags & ImGuiHoveredFlags_ChildWindows) |
| 9027 | result = IsWindowChildOf(ref_window, cur_window, popup_hierarchy, dock_hierarchy); |
| 9028 | else |
| 9029 | result = (ref_window == cur_window); |
| 9030 | if (!result) |
| 9031 | return false; |
| 9032 | } |
| 9033 | |
| 9034 | if (!IsWindowContentHoverable(ref_window, flags)) |
| 9035 | return false; |
| 9036 | if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) |
| 9037 | if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != ref_window->MoveId) |
| 9038 | return false; |
| 9039 | |
| 9040 | // When changing hovered window we requires a bit of stationary delay before activating hover timer. |
| 9041 | // FIXME: We don't support delay other than stationary one for now, other delay would need a way |
| 9042 | // to fulfill the possibility that multiple IsWindowHovered() with varying flag could return true |
| 9043 | // for different windows of the hierarchy. Possibly need a Hash(Current+Flags) ==> (Timer) cache. |
| 9044 | // We can implement this for _Stationary because the data is linked to HoveredWindow rather than CurrentWindow. |
| 9045 | if (flags & ImGuiHoveredFlags_ForTooltip) |
| 9046 | flags = ApplyHoverFlagsForTooltip(flags, g.Style.HoverFlagsForTooltipMouse); |
| 9047 | if ((flags & ImGuiHoveredFlags_Stationary) != 0 && g.HoverWindowUnlockedStationaryId != ref_window->ID) |
| 9048 | return false; |
| 9049 | |
| 9050 | return true; |
| 9051 | } |
| 9052 | |
| 9053 | ImGuiID ImGui::GetWindowDockID() |
| 9054 | { |
nothing calls this directly
no test coverage detected