Table of Contents

Struct MouseState

Namespace
Microsoft.Xna.Framework.Input
Assembly
MonoGame.Framework.dll

Represents a mouse state with cursor position and button press information.

public struct MouseState
Inherited Members

Constructors

MouseState(int, int, int, ButtonState, ButtonState, ButtonState, ButtonState, ButtonState)

Initializes a new instance of the MouseState.

public MouseState(int x, int y, int scrollWheel, ButtonState leftButton, ButtonState middleButton, ButtonState rightButton, ButtonState xButton1, ButtonState xButton2)

Parameters

x int

Horizontal position of the mouse in relation to the window.

y int

Vertical position of the mouse in relation to the window.

scrollWheel int

Mouse scroll wheel's value.

leftButton ButtonState

Left mouse button's state.

middleButton ButtonState

Middle mouse button's state.

rightButton ButtonState

Right mouse button's state.

xButton1 ButtonState

XBUTTON1's state.

xButton2 ButtonState

XBUTTON2's state.

Remarks

Normally GetState() should be used to get mouse current state. The constructor is provided for simulating mouse input.

MouseState(int, int, int, ButtonState, ButtonState, ButtonState, ButtonState, ButtonState, int)

Initializes a new instance of the MouseState.

public MouseState(int x, int y, int scrollWheel, ButtonState leftButton, ButtonState middleButton, ButtonState rightButton, ButtonState xButton1, ButtonState xButton2, int horizontalScrollWheel)

Parameters

x int

Horizontal position of the mouse in relation to the window.

y int

Vertical position of the mouse in relation to the window.

scrollWheel int

Mouse scroll wheel's value.

leftButton ButtonState

Left mouse button's state.

middleButton ButtonState

Middle mouse button's state.

rightButton ButtonState

Right mouse button's state.

xButton1 ButtonState

XBUTTON1's state.

xButton2 ButtonState

XBUTTON2's state.

horizontalScrollWheel int

Mouse horizontal scroll wheel's value.

Remarks

Normally GetState() should be used to get mouse current state. The constructor is provided for simulating mouse input.

Properties

HorizontalScrollWheelValue

Returns the cumulative horizontal scroll wheel value since the game start

public int HorizontalScrollWheelValue { get; }

Property Value

int

LeftButton

Gets state of the left mouse button.

public ButtonState LeftButton { get; }

Property Value

ButtonState

MiddleButton

Gets state of the middle mouse button.

public ButtonState MiddleButton { get; }

Property Value

ButtonState

Position

Gets cursor position.

public Point Position { get; }

Property Value

Point

RightButton

Gets state of the right mouse button.

public ButtonState RightButton { get; }

Property Value

ButtonState

ScrollWheelValue

Returns cumulative scroll wheel value since the game start.

public int ScrollWheelValue { get; }

Property Value

int

X

Gets horizontal position of the cursor in relation to the window.

public int X { get; }

Property Value

int

XButton1

Gets state of the XButton1.

public ButtonState XButton1 { get; }

Property Value

ButtonState

XButton2

Gets state of the XButton2.

public ButtonState XButton2 { get; }

Property Value

ButtonState

Y

Gets vertical position of the cursor in relation to the window.

public int Y { get; }

Property Value

int

Methods

Equals(object)

Compares whether current instance is equal to specified object.

public override bool Equals(object obj)

Parameters

obj object

The MouseState to compare.

Returns

bool

GetHashCode()

Gets the hash code for MouseState instance.

public override int GetHashCode()

Returns

int

Hash code of the object.

ToString()

Returns a string describing the mouse state.

public override string ToString()

Returns

string

Operators

operator ==(MouseState, MouseState)

Compares whether two MouseState instances are equal.

public static bool operator ==(MouseState left, MouseState right)

Parameters

left MouseState

MouseState instance on the left of the equal sign.

right MouseState

MouseState instance on the right of the equal sign.

Returns

bool

true if the instances are equal; false otherwise.

operator !=(MouseState, MouseState)

Compares whether two MouseState instances are not equal.

public static bool operator !=(MouseState left, MouseState right)

Parameters

left MouseState

MouseState instance on the left of the equal sign.

right MouseState

MouseState instance on the right of the equal sign.

Returns

bool

true if the objects are not equal; false otherwise.