SFML community forums

General => Feature requests => Topic started by: nitram_cero on December 10, 2008, 12:09:43 am

Title: Relative mouse position delta in sf::Event::MouseMoveEvent
Post by: nitram_cero on December 10, 2008, 12:09:43 am
So there is no to keep track of the last position.

Good for dragging objects or the viewport.

Regards
-Martin
Title: Relative mouse position delta in sf::Event::MouseMoveEvent
Post by: Wizzard on December 10, 2008, 06:11:59 am
Just do it yourself.

The SFML is supposed to be minimalistic.
Title: Relative mouse position delta in sf::Event::MouseMoveEvent
Post by: nitram_cero on December 10, 2008, 02:58:49 pm
I could derive from RenderWindow to keep track, and access it everywhere  :roll: , other ways involve adding a "Last Mouse Position" variables in a lot of places and really error-prone.

It's a commodity, I know, but it's useful.

You can't say this lib is minimalistic thou... it's really big.
It's easy to learn, easy to understand, pretty verbose, well documented... but it's far from minimal.

Compare it with "raw" SDL... You'll know what I mean (loading yourself the audio buffer, accessing pixels, no loading of images other than BMP... that's minimalistic)


Adding two variables to the event struct doesn't bloat the code.

Regards
-Martín
Title: Relative mouse position delta in sf::Event::MouseMoveEvent
Post by: Laurent on December 10, 2008, 03:07:30 pm
The problem with a delta is that it will sometimes be wrong, when the mouse leaves and re-enter the window.
Title: Relative mouse position delta in sf::Event::MouseMoveEvent
Post by: nitram_cero on December 11, 2008, 06:59:30 pm
It can be worked with a flag.
The first time of a MouseMove event, as there is no saved last position, it could be flagged, and the delta would be (0,0).

After the first MouseMove, the flag is cleared and the last position saved.
Next time a proper delta is sent in the event.

If the cursor exits the window (I'm sure there is a way to know in every platform), the flag would be set and then again (0,0) will be the delta in the  next event.

When I have more time I'll give it a try myself and post the code if it works.

Regards
-Martín