Interface IMouseManager
Reports the mouse's buttons, position and clicks, comparing each frame with the one before.
public interface IMouseManager
Properties
CurrentPosition
The pointer position this frame, in logical coordinates when a transformer is set.
Vector2 CurrentPosition { get; }
Property Value
CurrentState
The mouse state this frame.
Mouse.Snapshot CurrentState { get; }
Property Value
CursorVisible
Whether the cursor is shown. Starts as MouseVisible says, and may be changed at any time.
bool CursorVisible { get; set; }
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.
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.
float DoubleClickRadius { get; set; }
Property Value
IsClicked
Whether the left button went down this frame.
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.
bool IsDoubleClicked { get; }
Property Value
IsPressed
Whether the left button is held.
bool IsPressed { get; }
Property Value
IsReleased
Whether the left button went up this frame.
bool IsReleased { get; }
Property Value
IsRightClicked
The frame the right button went down, edge-triggered against the previous snapshot exactly as IsClicked is.
bool IsRightClicked { get; }
Property Value
Remarks
Both buttons have always been in the snapshot; only the left one had these derived for it, so anything wanting a right-click had to reach past this interface and compare the two snapshots itself. A secondary action on a click is common enough -- an editor erasing what the left button paints, a context menu -- to be worth deriving once here.
IsRightPressed
The right button, held.
bool IsRightPressed { get; }
Property Value
IsRightReleased
The frame the right button came up.
bool IsRightReleased { get; }
Property Value
PreviousState
The mouse state the frame before.
Mouse.Snapshot PreviousState { get; }
Property Value
RawPosition
The pointer position in window pixels.
Vector2 RawPosition { get; }
Property Value
TransformedPosition
The pointer position after the transformer. Same as RawPosition when there is no transformer.
Vector2 TransformedPosition { get; }
Property Value
Transformer
Converts window pixels to logical coordinates. Null leaves positions in window pixels.
IMouseCoordinateTransformer Transformer { get; set; }
Property Value
Methods
IsHovering(Rectangle)
Whether the pointer is over rectangle.
bool IsHovering(Rectangle rectangle)
Parameters
rectangleRectangle
Returns
Update(IGameTime)
Reads the mouse for this frame. Call it once a frame.
void Update(IGameTime gameTime)
Parameters
gameTimeIGameTime