mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-21 01:39:32 +00:00
minor changes to mouse wheel event args
This commit is contained in:
@@ -7,18 +7,20 @@ namespace MonoGame.Extended.InputListeners
|
||||
public class MouseEventArgs : EventArgs
|
||||
{
|
||||
internal MouseEventArgs(TimeSpan time, MouseState previousState, MouseState currentState,
|
||||
MouseButton button = MouseButton.None, int? scrollWheelValue = null, int? scrollWheelDelta = null)
|
||||
MouseButton button = MouseButton.None)
|
||||
{
|
||||
PreviousState = previousState;
|
||||
CurrentState = currentState;
|
||||
Position = new Point(currentState.X, currentState.Y);
|
||||
Button = button;
|
||||
ScrollWheelValue = scrollWheelValue;
|
||||
ScrollWheelDelta = scrollWheelDelta;
|
||||
ScrollWheelValue = currentState.ScrollWheelValue;
|
||||
ScrollWheelDelta = currentState.ScrollWheelValue - previousState.ScrollWheelValue;
|
||||
Time = time;
|
||||
}
|
||||
|
||||
public TimeSpan Time { get; private set; }
|
||||
// not sure if we want the time to be part of the public API?
|
||||
internal TimeSpan Time { get; private set; }
|
||||
|
||||
public MouseState PreviousState { get; private set; }
|
||||
public MouseState CurrentState { get; private set; }
|
||||
public MouseButton Button { get; private set; }
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace MonoGame.Extended.InputListeners
|
||||
|
||||
internal MouseListener(MouseListenerSettings settings)
|
||||
{
|
||||
_doubleClickMilliseconds = settings.DoubleClickMilliseconds;
|
||||
_dragThreshold = settings.DragThreshold;
|
||||
DoubleClickMilliseconds = settings.DoubleClickMilliseconds;
|
||||
DragThreshold = settings.DragThreshold;
|
||||
}
|
||||
|
||||
private readonly int _doubleClickMilliseconds;
|
||||
private readonly int _dragThreshold;
|
||||
public int DoubleClickMilliseconds { get; private set; }
|
||||
public int DragThreshold { get; private set; }
|
||||
|
||||
private MouseState _currentState;
|
||||
private MouseState _previousState;
|
||||
@@ -59,7 +59,7 @@ namespace MonoGame.Extended.InputListeners
|
||||
var clickMovement = DistanceBetween(args.Position, _mouseDownArgs.Position);
|
||||
|
||||
// If the mouse hasn't moved much between mouse down and mouse up
|
||||
if (clickMovement < _dragThreshold)
|
||||
if (clickMovement < DragThreshold)
|
||||
{
|
||||
RaiseEvent(MouseClicked, args);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace MonoGame.Extended.InputListeners
|
||||
// If the last click was recent
|
||||
var clickMilliseconds = (args.Time - _previousClickArgs.Time).TotalMilliseconds;
|
||||
|
||||
if (clickMilliseconds <= _doubleClickMilliseconds)
|
||||
if (clickMilliseconds <= DoubleClickMilliseconds)
|
||||
RaiseEvent(MouseDoubleClicked, args);
|
||||
|
||||
_previousClickArgs = null;
|
||||
@@ -107,12 +107,7 @@ namespace MonoGame.Extended.InputListeners
|
||||
|
||||
// Handle mouse wheel events.
|
||||
if (_previousState.ScrollWheelValue != _currentState.ScrollWheelValue)
|
||||
{
|
||||
var value = _currentState.ScrollWheelValue / 120;
|
||||
var delta = (_currentState.ScrollWheelValue - _previousState.ScrollWheelValue) / 120;
|
||||
|
||||
RaiseEvent(MouseWheelMoved, new MouseEventArgs(gameTime.TotalGameTime, _previousState, _currentState, MouseButton.None, value, delta));
|
||||
}
|
||||
RaiseEvent(MouseWheelMoved, new MouseEventArgs(gameTime.TotalGameTime, _previousState, _currentState));
|
||||
|
||||
_previousState = _currentState;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user