Fix tooltips in element search

Visible since c3cd4f1691, 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.
This commit is contained in:
Tamás Bálint Misius 2024-03-05 16:09:15 +01:00
parent ab28f93753
commit c85ebe4a0a
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -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;
}
}