Table of Contents

Class MouseManager

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

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

logger ILogger<MouseManager>
eventAggregator IEventAggregator

Properties

CurrentPosition

The pointer position this frame, in logical coordinates when a transformer is set.

public Vector2 CurrentPosition { get; }

Property Value

Vector2

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

Mouse.Snapshot

CursorVisible

Whether the cursor is shown. This is the same setting as IsVisible.

public bool CursorVisible { get; set; }

Property Value

bool

Difference

How far the pointer moved since the last update, in the same units as CurrentPosition.

public Vector2 Difference { get; }

Property Value

Vector2

DoubleClick

What counts as a double-click. Its interval and radius may be changed.

public DoubleClickDetector DoubleClick { get; }

Property Value

DoubleClickDetector

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

TimeSpan

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

float

IsClicked

Whether the left button went down this frame.

public 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.

public bool IsDoubleClicked { get; }

Property Value

bool

IsPressed

Whether the left button is held.

public bool IsPressed { get; }

Property Value

bool

IsReleased

Whether the left button went up this frame.

public bool IsReleased { get; }

Property Value

bool

IsRightClicked

Whether the right button went down this frame.

public bool IsRightClicked { get; }

Property Value

bool

IsRightPressed

Whether the right button is held.

public bool IsRightPressed { get; }

Property Value

bool

IsRightReleased

Whether the right button went up this frame.

public bool IsRightReleased { get; }

Property Value

bool

PreviousState

The mouse state the frame before.

public Mouse.Snapshot PreviousState { get; }

Property Value

Mouse.Snapshot

RawPosition

The pointer position in window pixels.

public Vector2 RawPosition { get; }

Property Value

Vector2

TransformedPosition

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

public Vector2 TransformedPosition { get; }

Property Value

Vector2

Transformer

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

public IMouseCoordinateTransformer Transformer { get; set; }

Property Value

IMouseCoordinateTransformer

Methods

IsHovering(Rectangle)

Whether the pointer is over rectangle.

public bool IsHovering(Rectangle rectangle)

Parameters

rectangle Rectangle

Returns

bool

Update(IGameTime)

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

public void Update(IGameTime gameTime)

Parameters

gameTime IGameTime