From bbe2430be90029caad38734cab62ce077f7ee6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 29 May 2023 11:22:33 +0200 Subject: [PATCH] Fix tooltips being active behind popups and outside clipping rects Ensure that tooltips are only activated when the associated UI element is currently the hot item. This prevents tooltips from being activated for UI elements that are currently not enabled due to them being behind a popup or outside of a clipping rect. --- src/game/client/components/tooltips.cpp | 5 +++-- src/game/client/components/tooltips.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/tooltips.cpp b/src/game/client/components/tooltips.cpp index f90f48451..4d7dd7970 100644 --- a/src/game/client/components/tooltips.cpp +++ b/src/game/client/components/tooltips.cpp @@ -30,6 +30,7 @@ void CTooltips::DoToolTip(const void *pID, const CUIRect *pNearRect, const char { uintptr_t ID = reinterpret_cast(pID); const auto result = m_Tooltips.emplace(ID, CTooltip{ + pID, *pNearRect, pText, WidthHint, @@ -44,7 +45,7 @@ void CTooltips::DoToolTip(const void *pID, const CUIRect *pNearRect, const char Tooltip.m_OnScreen = true; - if(UI()->MouseInside(&Tooltip.m_Rect)) + if(UI()->HotItem() == Tooltip.m_pID) { SetActiveTooltip(Tooltip); } @@ -56,7 +57,7 @@ void CTooltips::OnRender() { CTooltip &Tooltip = m_ActiveTooltip.value(); - if(!UI()->MouseInside(&Tooltip.m_Rect)) + if(UI()->HotItem() != Tooltip.m_pID) { Tooltip.m_OnScreen = false; ClearActiveTooltip(); diff --git a/src/game/client/components/tooltips.h b/src/game/client/components/tooltips.h index 7d89ef8b0..aaac1afec 100644 --- a/src/game/client/components/tooltips.h +++ b/src/game/client/components/tooltips.h @@ -11,6 +11,7 @@ struct CTooltip { + const void *m_pID; CUIRect m_Rect; const char *m_pText; float m_WidthHint;