Table of Contents

Interface IMouseManager

Namespace
BSGameLib.Game.Input
Assembly
BSGameLib.Game.dll

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

Vector2

CurrentState

The mouse state this frame.

Mouse.Snapshot CurrentState { get; }

Property Value

Mouse.Snapshot

CursorVisible

Whether the cursor is shown. Starts as MouseVisible says, and may be changed at any time.

bool CursorVisible { get; set; }

Property Value

bool

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

TimeSpan

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

float

IsClicked

Whether the left button went down this frame.

bool IsClicked { get; }

Property Value

bool

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

bool

IsPressed

Whether the left button is held.

bool IsPressed { get; }

Property Value

bool

IsReleased

Whether the left button went up this frame.

bool IsReleased { get; }

Property Value

bool

IsRightClicked

The frame the right button went down, edge-triggered against the previous snapshot exactly as IsClicked is.

bool IsRightClicked { get; }

Property Value

bool

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

bool

IsRightReleased

The frame the right button came up.

bool IsRightReleased { get; }

Property Value

bool

PreviousState

The mouse state the frame before.

Mouse.Snapshot PreviousState { get; }

Property Value

Mouse.Snapshot

RawPosition

The pointer position in window pixels.

Vector2 RawPosition { get; }

Property Value

Vector2

TransformedPosition

The pointer position after the transformer. Same as RawPosition when there is no transformer.

Vector2 TransformedPosition { get; }

Property Value

Vector2

Transformer

Converts window pixels to logical coordinates. Null leaves positions in window pixels.

IMouseCoordinateTransformer Transformer { get; set; }

Property Value

IMouseCoordinateTransformer

Methods

IsHovering(Rectangle)

Whether the pointer is over rectangle.

bool IsHovering(Rectangle rectangle)

Parameters

rectangle Rectangle

Returns

bool

Update(IGameTime)

Reads the mouse for this frame. Call it once a frame.

void Update(IGameTime gameTime)

Parameters

gameTime IGameTime