From ae5d099b8175e9618bf5773d04e7876b90606b1b Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sat, 4 Aug 2012 14:14:23 +0100 Subject: [PATCH] Fire OnMouseEnter events for components that are added under the mouse cursor, fixes issue #37 --- src/interface/Window.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/interface/Window.cpp b/src/interface/Window.cpp index f909af058..39318eb1f 100644 --- a/src/interface/Window.cpp +++ b/src/interface/Window.cpp @@ -40,6 +40,10 @@ void Window::AddComponent(Component* c) { c->SetParentWindow(this); 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 {