Fix panels forwarding clicks from anywhere
Very similar toab28f93753
. Broken by69e0a8b0aa
where I added an extra MouseDownInside check to the OnMouseDown (used to be OnMouseClick) of every component except that of sliders AND apparently panels, great.
This commit is contained in:
parent
4b866c409a
commit
bb471e63e1
@ -114,32 +114,35 @@ void Panel::OnMouseClick(int localx, int localy, unsigned button)
|
|||||||
|
|
||||||
void Panel::OnMouseDown(int x, int y, unsigned button)
|
void Panel::OnMouseDown(int x, int y, unsigned button)
|
||||||
{
|
{
|
||||||
auto localx = x - Position.X;
|
if (MouseDownInside)
|
||||||
auto localy = y - Position.Y;
|
|
||||||
//check if clicked a child
|
|
||||||
for(int i = children.size()-1; i >= 0 ; --i)
|
|
||||||
{
|
{
|
||||||
//child must be enabled
|
auto localx = x - Position.X;
|
||||||
if(children[i]->Enabled)
|
auto localy = y - Position.Y;
|
||||||
|
//check if clicked a child
|
||||||
|
for(int i = children.size()-1; i >= 0 ; --i)
|
||||||
{
|
{
|
||||||
//is mouse inside?
|
//child must be enabled
|
||||||
if( localx >= children[i]->Position.X + ViewportPosition.X &&
|
if(children[i]->Enabled)
|
||||||
localy >= children[i]->Position.Y + ViewportPosition.Y &&
|
|
||||||
localx < children[i]->Position.X + ViewportPosition.X + children[i]->Size.X &&
|
|
||||||
localy < children[i]->Position.Y + ViewportPosition.Y + children[i]->Size.Y )
|
|
||||||
{
|
{
|
||||||
GetParentWindow()->FocusComponent(children[i]);
|
//is mouse inside?
|
||||||
children[i]->MouseDownInside = true;
|
if( localx >= children[i]->Position.X + ViewportPosition.X &&
|
||||||
break;
|
localy >= children[i]->Position.Y + ViewportPosition.Y &&
|
||||||
|
localx < children[i]->Position.X + ViewportPosition.X + children[i]->Size.X &&
|
||||||
|
localy < children[i]->Position.Y + ViewportPosition.Y + children[i]->Size.Y )
|
||||||
|
{
|
||||||
|
GetParentWindow()->FocusComponent(children[i]);
|
||||||
|
children[i]->MouseDownInside = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
XOnMouseDown(x, y, button);
|
XOnMouseDown(x, y, button);
|
||||||
for (size_t i = 0; i < children.size(); ++i)
|
for (size_t i = 0; i < children.size(); ++i)
|
||||||
{
|
{
|
||||||
if(children[i]->Enabled)
|
if(children[i]->Enabled)
|
||||||
children[i]->OnMouseDown(x - Position.X - ViewportPosition.X, y - Position.Y - ViewportPosition.Y, button);
|
children[i]->OnMouseDown(x - Position.X - ViewportPosition.X, y - Position.Y - ViewportPosition.Y, button);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user