Class MouseComponent
Inherited Members
Namespace: OpenTK.Platform.Native.Windows
Assembly: OpenTK.Platform.dll
Syntax
public class MouseComponent : IMouseComponent, IPalComponent
Properties
CanSetMousePosition
If it's possible to set the position of the mouse using SetGlobalPosition(Vector2).
Declaration
public bool CanSetMousePosition { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
Logger
The logger that this component uses to log diagnostic messages.
Declaration
public ILogger? Logger { get; set; }
Property Value
Type | Description |
---|---|
ILogger |
See Also
Name
Name of the abstraction layer component.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
Provides
Specifies which PAL components this object provides.
Declaration
public PalComponents Provides { get; }
Property Value
Type | Description |
---|---|
PalComponents |
SupportsRawMouseMotion
If raw mouse motion is supported on this platform. If this is falseIsRawMouseMotionEnabled(WindowHandle) and EnableRawMouseMotion(WindowHandle, bool) should not be used.
Declaration
public bool SupportsRawMouseMotion { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
Methods
EnableRawMouseMotion(WindowHandle, bool)
Enables or disables raw mouse motion for a specific window. When raw mouse motion is enabled the window will receive RawMouseMoveEventArgs events, in addition to the normal MouseMoveEventArgs events. Check that SupportsRawMouseMotion is true before using this.
Declaration
public void EnableRawMouseMotion(WindowHandle handle, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | |
bool | enabled |
See Also
GetGlobalMouseState(out MouseState)
Fills the state
struct with the current mouse state.
This function may query the mouse state outside of event processing to get the position of the mouse at the time this function is called.
The Position will be the screen mouse position and not virtual coordinates described by Locked.
The Position is in window screen coordinates.
Declaration
public void GetGlobalMouseState(out MouseState state)
Parameters
Type | Name | Description |
---|---|---|
MouseState | state | The current mouse state. |
See Also
GetGlobalPosition(out Vector2)
Get the global mouse cursor position. This function may query the mouse position outside of event processing to get the position of the mouse at the time this function is called. The mouse position returned is the mouse position as it is on screen, it will not return virtual coordinates when using Locked.
Declaration
public void GetGlobalPosition(out Vector2 globalPosition)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | globalPosition | Coordinate of the mouse in screen coordinates. |
See Also
GetMouseState(WindowHandle, out MouseState)
Fills the state
struct with the current mouse state for the specified window.
This function takes into consideration only the mouse events that the specified window has received and does not represent global state.
If the window has locked the cursor using Locked, this function will return virtual coordinates (unlike GetGlobalMouseState(out MouseState)).
The Position is in window relative coordinates.
Declaration
public void GetMouseState(WindowHandle window, out MouseState state)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | window | The window to get the mouse state from. |
MouseState | state | The current mouse state. |
See Also
GetPosition(WindowHandle, out Vector2)
Gets the mouse position as seen from the specified window. This function takes into consideration only the mouse events that the specified window has received and does not represent global state. If the window has locked the cursor using Locked, this function will return virtual coordinates (unlike GetGlobalPosition(out Vector2i)).
Declaration
public void GetPosition(WindowHandle window, out Vector2 position)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | window | The window to get the mouse position for. |
Vector2 | position | Coordinate of the mouse in client coordinates. |
See Also
Initialize(ToolkitOptions)
Initialize the component.
Declaration
public void Initialize(ToolkitOptions options)
Parameters
Type | Name | Description |
---|---|---|
ToolkitOptions | options | The options to initialize the component with. |
See Also
IsRawMouseMotionEnabled(WindowHandle)
Returns whether raw mouse motion is enabled for the given window or not. Check that SupportsRawMouseMotion is true before using this.
Declaration
public bool IsRawMouseMotionEnabled(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle |
Returns
Type | Description |
---|---|
bool | If raw mouse motion is enabled. |
See Also
SetGlobalPosition(Vector2)
Set the global mouse cursor position. Check that CanSetMousePosition is true before using this.
Declaration
public void SetGlobalPosition(Vector2 newGlobalPosition)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | newGlobalPosition | New coordinate of the mouse in screen space. |
See Also
Uninitialize()
Uninitialize the component. Frees any native resources used by the component.
Declaration
public void Uninitialize()