SFML community forums

General => Feature requests => Topic started by: Tank on September 22, 2009, 01:49:51 am

Title: Mouse position in MouseWheelMoved event
Post by: Tank on September 22, 2009, 01:49:51 am
Hey,

is it possible to add mouse positions to the MouseWheelEvent structure? This is currently only possible through sf::Input(). Unfortunately I don't have access to sf::Window::GetInput() where I need the positions.
Title: Mouse position in MouseWheelMoved event
Post by: Hiura on September 22, 2009, 08:31:44 am
As the mouse hasn't move since the last MouseMoved event you don't need this information one more time ( it's the same ) .
Title: Mouse position in MouseWheelMoved event
Post by: Tank on September 22, 2009, 12:04:26 pm
Well, the same goes for MouseButtonEvent, doesn't it?

And it's good as it is because it's comfortable and makes sense: The user pressed a button, where? And I want: The user moved the wheel, where?
Title: Mouse position in MouseWheelMoved event
Post by: Laurent on September 22, 2009, 12:18:43 pm
Quote from: "Tank"
Well, the same goes for MouseButtonEvent, doesn't it?

And it's good as it is because it's comfortable and makes sense: The user pressed a button, where? And I want: The user moved the wheel, where?

Agreed, and added to the task list.
Title: Mouse position in MouseWheelMoved event
Post by: Tank on September 22, 2009, 01:35:43 pm
Thanks Laurent.

I already did the (small) patch yesterday, so if you're interested, you may want to apply it:
Code: [Select]
+++ src/SFML/Window/Win32/WindowImplWin32.cpp 2009-09-22 01:55:41.000000000 +0200
@@ -562,6 +562,8 @@
Event event;
event.Type = Event::MouseWheelMoved;
event.MouseWheel.Delta = static_cast<Int16>(HIWORD(wParam)) / 120;
+ event.MouseWheel.X = LOWORD(lParam);
+ event.MouseWheel.Y = HIWORD(lParam);
SendEvent(event);
break;
}
+++ src/SFML/Window/Linux/WindowImplX11.cpp 2009-09-22 01:54:29.000000000 +0200
@@ -819,6 +819,8 @@
Event event;
event.Type = Event::MouseWheelMoved;
event.MouseWheel.Delta = windowEvent.xbutton.button == Button4 ? 1 : -1;
+ event.MouseWheel.X = windowEvent.xbutton.x;
+ event.MouseWheel.Y = windowEvent.xbutton.y;
SendEvent(event);
}
break;


Edit: Just noticed that it's missing the "int X" and "int Y" members in the MouseWheelEvent struct.
Title: Mouse position in MouseWheelMoved event
Post by: Laurent on September 22, 2009, 03:47:50 pm
Thanks for the patch, but there's much more to change (CSFML, SFML.Net, tutorials, documentation, ...) ;)
Title: Mouse position in MouseWheelMoved event
Post by: Tank on September 22, 2009, 04:22:05 pm
True. :)
Title: Mouse position in MouseWheelMoved event
Post by: Laurent on October 27, 2009, 05:15:11 pm
It's implemented now.

By the way, your patch has an error: on Windows, and unlike other mouse events, WM_MOUSEWHEEL gives the mouse position in screen coordinates; so it has to be converted to window coordinates ;)
Title: Mouse position in MouseWheelMoved event
Post by: Tank on October 27, 2009, 11:00:23 pm
Thank you very much.

Oh okay, I haven't read the MSDN carefully enough, I guess. ;)