mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
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.
This commit is contained in:
parent
57f1b1a8c6
commit
bbe2430be9
|
@ -30,6 +30,7 @@ void CTooltips::DoToolTip(const void *pID, const CUIRect *pNearRect, const char
|
|||
{
|
||||
uintptr_t ID = reinterpret_cast<uintptr_t>(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();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
struct CTooltip
|
||||
{
|
||||
const void *m_pID;
|
||||
CUIRect m_Rect;
|
||||
const char *m_pText;
|
||||
float m_WidthHint;
|
||||
|
|
Loading…
Reference in a new issue