mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
FS#131 - Add mouse position to the sf::Event::MouseWheelMoved event
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1249 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
0d66fa1776
commit
688a8f15da
@ -242,6 +242,8 @@ struct sfMouseWheelEvent
|
||||
{
|
||||
sfEventType Type;
|
||||
int Delta;
|
||||
int X;
|
||||
int Y;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -62,6 +62,8 @@ inline void ConvertEvent(const sf::Event& SFMLEvent, sfEvent* event)
|
||||
|
||||
case sfEvtMouseWheelMoved :
|
||||
event->MouseWheel.Delta = SFMLEvent.MouseWheel.Delta;
|
||||
event->MouseWheel.X = SFMLEvent.MouseWheel.X;
|
||||
event->MouseWheel.Y = SFMLEvent.MouseWheel.Y;
|
||||
break;
|
||||
|
||||
case sfEvtMouseButtonPressed :
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -294,6 +294,12 @@ namespace SFML
|
||||
{
|
||||
/// <summary>Scroll amount</summary>
|
||||
public int Delta;
|
||||
|
||||
/// <summary>X coordinate of the mouse cursor</summary>
|
||||
public int X;
|
||||
|
||||
/// <summary>Y coordinate of the mouse cursor</summary>
|
||||
public int Y;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -132,10 +132,18 @@ namespace SFML
|
||||
public MouseWheelEventArgs(MouseWheelEvent e)
|
||||
{
|
||||
Delta = e.Delta;
|
||||
X = e.X;
|
||||
Y = e.Y;
|
||||
}
|
||||
|
||||
/// <summary>Scroll amount</summary>
|
||||
public int Delta;
|
||||
|
||||
/// <summary>X coordinate of the mouse cursor</summary>
|
||||
public int X;
|
||||
|
||||
/// <summary>Y coordinate of the mouse cursor</summary>
|
||||
public int Y;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -223,8 +223,8 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
struct MouseMoveEvent
|
||||
{
|
||||
int X; ///< X position of the mouse, relative to the left of the owner window
|
||||
int Y; ///< Y position of the mouse, relative to the top of the owner window
|
||||
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
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -235,8 +235,8 @@ public :
|
||||
struct MouseButtonEvent
|
||||
{
|
||||
Mouse::Button Button; ///< Code of the button that has been pressed
|
||||
int X; ///< X position of the mouse, relative to the left of the owner window
|
||||
int Y; ///< Y position of the mouse, relative to the top of the owner window
|
||||
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
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -246,6 +246,8 @@ public :
|
||||
struct MouseWheelEvent
|
||||
{
|
||||
int Delta; ///< Number of ticks the wheel has moved (positive is up, negative is down)
|
||||
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
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -532,9 +532,17 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
// Mouse wheel event
|
||||
case WM_MOUSEWHEEL :
|
||||
{
|
||||
// Mouse position is in screen coordinates, convert it to window coordinates
|
||||
POINT position;
|
||||
position.x = LOWORD(lParam);
|
||||
position.y = HIWORD(lParam);
|
||||
ScreenToClient(myHandle, &position);
|
||||
|
||||
Event event;
|
||||
event.Type = Event::MouseWheelMoved;
|
||||
event.MouseWheel.Delta = static_cast<Int16>(HIWORD(wParam)) / 120;
|
||||
event.MouseButton.X = position.x;
|
||||
event.MouseButton.Y = position.y;
|
||||
SendEvent(event);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user