From c85ebe4a0a95d02c7a7eb1181a5b632c433093a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Tue, 5 Mar 2024 16:09:15 +0100 Subject: [PATCH] Fix tooltips in element search Visible since c3cd4f1691b4, which made element search scrollable. They would behave as if the scroll panel was never actually scrolled, i.e. tooltips might be shown that belonged to buttons far outside the visible part of the panel's inner area. This was because Panel invoked the OnMouseHover of its children wrong, without taking scrolling into account. --- src/gui/interface/Panel.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/interface/Panel.cpp b/src/gui/interface/Panel.cpp index 3aa28451d..119989e14 100644 --- a/src/gui/interface/Panel.cpp +++ b/src/gui/interface/Panel.cpp @@ -150,12 +150,14 @@ void Panel::OnMouseHover(int localx, int localy) { if (children[i]->Enabled) { - if( localx >= children[i]->Position.X && - localy >= children[i]->Position.Y && - localx < children[i]->Position.X + children[i]->Size.X && - localy < children[i]->Position.Y + children[i]->Size.Y ) + auto px = children[i]->Position.X + ViewportPosition.X; + auto py = children[i]->Position.Y + ViewportPosition.Y; + if( localx >= px && + localy >= py && + localx < px + children[i]->Size.X && + localy < py + children[i]->Size.Y ) { - children[i]->OnMouseHover(localx - children[i]->Position.X, localy - children[i]->Position.Y); + children[i]->OnMouseHover(localx - px, localy - py); break; } }