SFML community forums

General => Feature requests => Topic started by: Magtheridon96 on June 23, 2013, 12:24:14 pm

Title: Mouse Position Delta
Post by: Magtheridon96 on June 23, 2013, 12:24:14 pm
It would be nice if the MouseMoveEvent struct:

struct MouseMoveEvent
{
    int x; ///< X position of the mouse pointer, relative to the left of the owner window
    int y; ///< Y position of the mouse pointer, relative to the top of the owner window
};

were to have 2 more useful members:

struct MouseMoveEvent
{
    int x;      ///< X position of the mouse pointer, relative to the left of the owner window
    int y;      ///< Y position of the mouse pointer, relative to the top of the owner window
    int deltaX; ///< Difference in X position of the mouse pointer, relative to the left of the owner window
    int deltaY; ///< Difference in Y position of the mouse pointer, relative to the top of the owner window
};

Currently, I have to calculate them manually by constantly tracking MouseMoved events.
I think it would be cleaner to have SFML do it.

The implementation should be simple, but that's none of my business, so I'll leave it at that.
Title: Re: Mouse Position Delta
Post by: Laurent on June 23, 2013, 12:56:29 pm
Quote
Currently, I have to calculate them manually by constantly tracking MouseMoved events.
You already constantly track MouseMoved events anyway, so calculating the delta on your side is just an extra line of code. Is it worth requesting it as a new feature?

I agree, it should be simple. But things may be trickier in border cases, like when focus is lost/gained, when mouse enters/leaves the window, when the mouse is moved programmatically, etc.
Title: Re: Mouse Position Delta
Post by: Magtheridon96 on June 23, 2013, 01:36:17 pm
Quote
But things may be trickier in border cases, like when focus is lost/gained, when mouse enters/leaves the window, when the mouse is moved programmatically, etc.

Well, that settles it :v
I guess it might not be worth it after all.