Class MouseState
Encapsulates the state of a mouse device.
Inherited Members
Namespace: OpenTK.Windowing.GraphicsLibraryFramework
Assembly: OpenTK.Windowing.GraphicsLibraryFramework.dll
Syntax
public class MouseState
Properties
Delta
Gets a Vector2 representing the amount that the mouse moved since the last frame. This does not necessarily correspond to pixels, for example in the case of raw input.
Declaration
public Vector2 Delta { get; }
Property Value
Type | Description |
---|---|
Vector2 |
IsAnyButtonDown
Gets a value indicating whether any button is down.
Declaration
public bool IsAnyButtonDown { get; }
Property Value
Type | Description |
---|---|
bool |
|
this[MouseButton]
Gets a bool indicating whether the specified MouseButton is pressed.
Declaration
public bool this[MouseButton button] { get; }
Parameters
Type | Name | Description |
---|---|---|
MouseButton | button | The MouseButton to check. |
Property Value
Type | Description |
---|---|
bool |
|
Position
Gets a Vector2 representing the absolute position of the pointer in the current frame, relative to the top-left corner of the contents of the window.
Declaration
public Vector2 Position { get; }
Property Value
Type | Description |
---|---|
Vector2 |
PreviousPosition
Gets a Vector2 representing the absolute position of the pointer in the previous frame, relative to the top-left corner of the contents of the window.
Declaration
public Vector2 PreviousPosition { get; }
Property Value
Type | Description |
---|---|
Vector2 |
PreviousScroll
Get a Vector2 representing the position of the mouse wheel.
Declaration
public Vector2 PreviousScroll { get; }
Property Value
Type | Description |
---|---|
Vector2 |
PreviousX
Gets an integer representing the absolute x position of the pointer, in window pixel coordinates.
Declaration
public float PreviousX { get; }
Property Value
Type | Description |
---|---|
float |
PreviousY
Gets an integer representing the absolute y position of the pointer, in window pixel coordinates.
Declaration
public float PreviousY { get; }
Property Value
Type | Description |
---|---|
float |
Scroll
Get a Vector2 representing the position of the mouse wheel.
Declaration
public Vector2 Scroll { get; }
Property Value
Type | Description |
---|---|
Vector2 |
ScrollDelta
Get a Vector2 representing the amount that the mouse wheel moved since the last frame.
Declaration
public Vector2 ScrollDelta { get; }
Property Value
Type | Description |
---|---|
Vector2 |
X
Gets an integer representing the absolute x position of the pointer, in window pixel coordinates.
Declaration
public float X { get; }
Property Value
Type | Description |
---|---|
float |
Y
Gets an integer representing the absolute y position of the pointer, in window pixel coordinates.
Declaration
public float Y { get; }
Property Value
Type | Description |
---|---|
float |
Methods
GetSnapshot()
Gets an immutable snapshot of this MouseState. This can be used to save the current mouse state for comparison later on.
Declaration
public MouseState GetSnapshot()
Returns
Type | Description |
---|---|
MouseState | Returns an immutable snapshot of this MouseState. |
IsButtonDown(MouseButton)
Gets a bool indicating whether this button is down.
Declaration
public bool IsButtonDown(MouseButton button)
Parameters
Type | Name | Description |
---|---|---|
MouseButton | button | The MouseButton to check. |
Returns
Type | Description |
---|---|
bool |
|
IsButtonPressed(MouseButton)
Gets whether the specified mouse button is pressed in the current frame but released in the previous frame.
Declaration
public bool IsButtonPressed(MouseButton button)
Parameters
Type | Name | Description |
---|---|---|
MouseButton | button | The mouse button to check. |
Returns
Type | Description |
---|---|
bool | True if the mouse button is pressed in this frame, but not the last frame. |
Remarks
"Frame" refers to invocations of
IsButtonReleased(MouseButton)
Gets whether the specified mouse button is released in the current frame but pressed in the previous frame.
Declaration
public bool IsButtonReleased(MouseButton button)
Parameters
Type | Name | Description |
---|---|---|
MouseButton | button | The mouse button to check. |
Returns
Type | Description |
---|---|
bool | True if the mouse button is released in this frame, but pressed the last frame. |
Remarks
"Frame" refers to invocations of
ToString()
Returns a string that represents the current MouseState.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current MouseState. |
Overrides
WasButtonDown(MouseButton)
Gets a bool indicating whether this button was down in the previous frame.
Declaration
public bool WasButtonDown(MouseButton button)
Parameters
Type | Name | Description |
---|---|---|
MouseButton | button | The MouseButton to check. |
Returns
Type | Description |
---|---|
bool |
|