Window::SetCursorPosition now triggers MouseMoved events

This commit is contained in:
Laurent Gomila 2011-05-30 18:56:49 +02:00
parent 0449e74dc3
commit d938899f5c
2 changed files with 3 additions and 27 deletions

View File

@ -497,8 +497,6 @@ private :
Clock myClock; ///< Clock for measuring the elapsed time between frames
Uint32 myLastFrameTime; ///< Time elapsed since last frame
unsigned int myFramerateLimit; ///< Current framerate limit
int mySetCursorPosX; ///< X coordinate passed to the last call to SetCursorPosition
int mySetCursorPosY; ///< Y coordinate passed to the last call to SetCursorPosition
};
} // namespace sf

View File

@ -48,9 +48,7 @@ Window::Window() :
myWindow (NULL),
myContext (NULL),
myLastFrameTime (0),
myFramerateLimit(0),
mySetCursorPosX (0xFFFF),
mySetCursorPosY (0xFFFF)
myFramerateLimit(0)
{
}
@ -61,9 +59,7 @@ Window::Window(VideoMode mode, const std::string& title, unsigned long style, co
myWindow (NULL),
myContext (NULL),
myLastFrameTime (0),
myFramerateLimit(0),
mySetCursorPosX (0xFFFF),
mySetCursorPosY (0xFFFF)
myFramerateLimit(0)
{
Create(mode, title, style, settings);
}
@ -74,9 +70,7 @@ Window::Window(WindowHandle handle, const ContextSettings& settings) :
myWindow (NULL),
myContext (NULL),
myLastFrameTime (0),
myFramerateLimit(0),
mySetCursorPosX (0xFFFF),
mySetCursorPosY (0xFFFF)
myFramerateLimit(0)
{
Create(handle, settings);
}
@ -251,13 +245,7 @@ void Window::ShowMouseCursor(bool show)
void Window::SetCursorPosition(unsigned int x, unsigned int y)
{
if (myWindow)
{
// Keep coordinates for later checking (to reject the generated MouseMoved event)
mySetCursorPosX = x;
mySetCursorPosY = y;
myWindow->SetCursorPosition(x, y);
}
}
@ -412,16 +400,6 @@ bool Window::FilterEvent(const Event& event)
if (event.Type == Event::Resized)
OnResize();
// Don't forward to the user MouseMove events generated by SetCursorPosition
if ((event.Type == Event::MouseMoved) &&
(event.MouseMove.X == mySetCursorPosX) &&
(event.MouseMove.Y == mySetCursorPosY))
{
mySetCursorPosX = 0xFFFF;
mySetCursorPosY = 0xFFFF;
return false;
}
return true;
}