Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Mouse position in MouseWheelMoved event  (Read 4661 times)

0 Members and 1 Guest are viewing this topic.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Mouse position in MouseWheelMoved event
« 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.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Mouse position in MouseWheelMoved event
« Reply #1 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 ) .
SFML / OS X developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Mouse position in MouseWheelMoved event
« Reply #2 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Mouse position in MouseWheelMoved event
« Reply #3 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.
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Mouse position in MouseWheelMoved event
« Reply #4 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Mouse position in MouseWheelMoved event
« Reply #5 on: September 22, 2009, 03:47:50 pm »
Thanks for the patch, but there's much more to change (CSFML, SFML.Net, tutorials, documentation, ...) ;)
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Mouse position in MouseWheelMoved event
« Reply #6 on: September 22, 2009, 04:22:05 pm »
True. :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Mouse position in MouseWheelMoved event
« Reply #7 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 ;)
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Mouse position in MouseWheelMoved event
« Reply #8 on: October 27, 2009, 11:00:23 pm »
Thank you very much.

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