Class MouseManager
The default mouse manager. It works out button edges and positions each frame, and publishes a MouseClickedEvent for each click.
public class MouseManager : IMouseManager
- Inheritance
-
MouseManager
- Implements
- Inherited Members
Constructors
MouseManager(ILogger<MouseManager>, IEventAggregator)
Created by dependency injection. Reads the mouse once, so that the first frame has a previous state.
public MouseManager(ILogger<MouseManager> logger, IEventAggregator eventAggregator)
Parameters
loggerILogger<MouseManager>eventAggregatorIEventAggregator
Properties
CurrentPosition
The pointer position this frame, in logical coordinates when a transformer is set.
public Vector2 CurrentPosition { get; }
Property Value
CurrentState
The mouse state this frame. Its X and Y are logical coordinates when a Transformer is set.
public Mouse.Snapshot CurrentState { get; }
Property Value
CursorVisible
Whether the cursor is shown. This is the same setting as IsVisible.
public bool CursorVisible { get; set; }
Property Value
Difference
How far the pointer moved since the last update, in the same units as CurrentPosition.
public Vector2 Difference { get; }
Property Value
DoubleClick
What counts as a double-click. Its interval and radius may be changed.
public DoubleClickDetector DoubleClick { get; }
Property Value
DoubleClickInterval
How long after a click a second one may come and still make a double-click. SDL's default is 500 ms.
public TimeSpan DoubleClickInterval { get; set; }
Property Value
DoubleClickRadius
How far apart, in window pixels, the two clicks of a double-click may be. SDL's default is 32.
public float DoubleClickRadius { get; set; }
Property Value
IsClicked
Whether the left button went down this frame.
public bool IsClicked { get; }
Property Value
IsDoubleClicked
The frame the left button went down for the second time in quick succession, in about the same place. True on the same frame as IsClicked, so something that selects on a click and acts on a double-click does both.
public bool IsDoubleClicked { get; }
Property Value
IsPressed
Whether the left button is held.
public bool IsPressed { get; }
Property Value
IsReleased
Whether the left button went up this frame.
public bool IsReleased { get; }
Property Value
IsRightClicked
Whether the right button went down this frame.
public bool IsRightClicked { get; }
Property Value
IsRightPressed
Whether the right button is held.
public bool IsRightPressed { get; }
Property Value
IsRightReleased
Whether the right button went up this frame.
public bool IsRightReleased { get; }
Property Value
PreviousState
The mouse state the frame before.
public Mouse.Snapshot PreviousState { get; }
Property Value
RawPosition
The pointer position in window pixels.
public Vector2 RawPosition { get; }
Property Value
TransformedPosition
The pointer position after the transformer. Same as RawPosition when there is no transformer.
public Vector2 TransformedPosition { get; }
Property Value
Transformer
Converts window pixels to logical coordinates. Null leaves positions in window pixels.
public IMouseCoordinateTransformer Transformer { get; set; }
Property Value
Methods
IsHovering(Rectangle)
Whether the pointer is over rectangle.
public bool IsHovering(Rectangle rectangle)
Parameters
rectangleRectangle
Returns
Update(IGameTime)
Reads the mouse for this frame. Call it once a frame.
public void Update(IGameTime gameTime)
Parameters
gameTimeIGameTime