Class MacOSCursorComponent
Inherited Members
Namespace: OpenTK.Platform.Native.macOS
Assembly: OpenTK.Platform.dll
Syntax
public class MacOSCursorComponent : ICursorComponent, IPalComponent
Properties
CanInspectSystemCursors
True if the backend supports inspecting system cursor handles. If true, functions like GetSize(CursorHandle, out int, out int) and GetHotspot(CursorHandle, out int, out int) works on system cursors. If false, these functions will fail.
Declaration
public bool CanInspectSystemCursors { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
CanLoadSystemCursors
True if the driver can load system cursors.
Declaration
public bool CanLoadSystemCursors { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
Logger
Provides a logger for this component.
Declaration
public ILogger? Logger { get; set; }
Property Value
Type | Description |
---|---|
ILogger |
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 |
Methods
Create(Frame[], float)
Creates an animated cursor from a collection of frames.
Declaration
public CursorHandle Create(MacOSCursorComponent.Frame[] frames, float delay)
Parameters
Type | Name | Description |
---|---|---|
Frame[] | frames | The frames of the animation. |
float | delay | The delay in seconds between frames of the animation. |
Returns
Type | Description |
---|---|
CursorHandle | The created animated cursor. |
Create(SystemCursorType)
Create a standard system cursor.
Declaration
public CursorHandle Create(SystemCursorType systemCursor)
Parameters
Type | Name | Description |
---|---|---|
SystemCursorType | systemCursor | Type of the standard cursor to load. |
Returns
Type | Description |
---|---|
CursorHandle | A handle to the created cursor. |
Remarks
This function is only supported if CanLoadSystemCursors is true.
Exceptions
Type | Condition |
---|---|
PalNotImplementedException | Driver does not implement this function. See CanLoadSystemCursors. |
PlatformException | System does not provide cursor type selected by |
Create(int, int, ReadOnlySpan<byte>, int, int)
Load a cursor image from memory.
Declaration
public CursorHandle Create(int width, int height, ReadOnlySpan<byte> image, int hotspotX, int hotspotY)
Parameters
Type | Name | Description |
---|---|---|
int | width | Width of the cursor image. |
int | height | Height of the cursor image. |
ReadOnlySpan<byte> | image | Buffer containing image data. |
int | hotspotX | The x coordinate of the cursor hotspot. |
int | hotspotY | The y coordinate of the cursor hotspot. |
Returns
Type | Description |
---|---|
CursorHandle | A handle to the created cursor. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ArgumentException |
|
Create(int, int, ReadOnlySpan<byte>, ReadOnlySpan<byte>, int, int)
Load a cursor image from memory.
Declaration
public CursorHandle Create(int width, int height, ReadOnlySpan<byte> colorData, ReadOnlySpan<byte> maskData, int hotspotX, int hotspotY)
Parameters
Type | Name | Description |
---|---|---|
int | width | Width of the cursor image. |
int | height | Height of the cursor image. |
ReadOnlySpan<byte> | colorData | Buffer containing color data. |
ReadOnlySpan<byte> | maskData | Buffer containing mask data. |
int | hotspotX | The x coordinate of the cursor hotspot. |
int | hotspotY | The y coordinate of the cursor hotspot. |
Returns
Type | Description |
---|---|
CursorHandle | A handle to the created handle. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ArgumentException |
|
Destroy(CursorHandle)
Destroy a cursor object.
Declaration
public void Destroy(CursorHandle handle)
Parameters
Type | Name | Description |
---|---|---|
CursorHandle | handle | Handle to a cursor object. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GetHotspot(CursorHandle, out int, out int)
Get the hotspot location of the mouse cursor. Getting the hotspot of a system cursor is not guaranteed to be possible, check CanInspectSystemCursors before trying.
Declaration
public void GetHotspot(CursorHandle handle, out int x, out int y)
Parameters
Type | Name | Description |
---|---|---|
CursorHandle | handle | Handle to a cursor object. |
int | x | X coordinate of the hotspot. |
int | y | Y coordinate of the hotspot. |
Remarks
If handle
is a system cursor and CanInspectSystemCursors is false this function will fail.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
See Also
GetSize(CursorHandle, out int, out int)
Get the size of the cursor image.
Declaration
public void GetSize(CursorHandle handle, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
CursorHandle | handle | Handle to a cursor object. |
int | width | Width of the cursor. |
int | height | Height of the cursor. |
Remarks
If handle
is a system cursor and CanInspectSystemCursors is false this function will fail.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
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. |
IsAnimatedCursor(CursorHandle)
Returns true if the cursor is an animated cursor.
Declaration
public bool IsAnimatedCursor(CursorHandle handle)
Parameters
Type | Name | Description |
---|---|---|
CursorHandle | handle | The cursor to check if it is an animated |
Returns
Type | Description |
---|---|
bool | True if the cursor is animated, false otherwise. |
IsSystemCursor(CursorHandle)
Returns true if this cursor is a system cursor.
Declaration
public bool IsSystemCursor(CursorHandle handle)
Parameters
Type | Name | Description |
---|---|---|
CursorHandle | handle | Handle to a cursor. |
Returns
Type | Description |
---|---|
bool | If the cursor is a system cursor or not. |
See Also
UpdateAnimation(CursorHandle, double)
Updates the animation of an animated cursor. When animated cursors change frame SetCursor(WindowHandle, CursorHandle?) needs to be called to properly animate. This function returns true if the cursor needs to be set again.
Declaration
public bool UpdateAnimation(CursorHandle handle, double deltaTime)
Parameters
Type | Name | Description |
---|---|---|
CursorHandle | handle | An animated cursor to update. |
double | deltaTime | The amount of time to advance the cursor animation. |
Returns
Type | Description |
---|---|
bool | True if the cursor frame has changed and SetCursor(WindowHandle, CursorHandle?) needs to be called for the cursor to update, false otherwise. |