Fire OnMouseEnter events for components that are added under the mouse cursor, fixes issue #37

This commit is contained in:
Simon Robertshaw 2012-08-04 14:14:23 +01:00
parent e06d8e4d15
commit ae5d099b81

View File

@ -40,6 +40,10 @@ void Window::AddComponent(Component* c)
{ {
c->SetParentWindow(this); c->SetParentWindow(this);
Components.push_back(c); Components.push_back(c);
if(Engine::Ref().GetMouseX() > Position.X + c->Position.X && Engine::Ref().GetMouseX() < Position.X + c->Position.X + c->Size.X &&
Engine::Ref().GetMouseY() > Position.Y + c->Position.Y && Engine::Ref().GetMouseY() < Position.Y + c->Position.Y + c->Size.Y)
c->OnMouseEnter(Engine::Ref().GetMouseX() - (Position.X + c->Position.X), Engine::Ref().GetMouseY() - (Position.Y + c->Position.Y));
} }
else else
{ {