Class

# MouseCursor

<div class="rst-class">

forsearch

</div>

Mouse

<div class="rst-class">

forsearch

</div>

Cursor

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to specify the appearance of the pointer.

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                    | Parameters                                                                                                                                | Returns | Shared |
|-----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `Constructor<mousecursor.constructor0>` | image As `Picture</api/graphics/picture>`, xHotSpot As `Integer</api/data_types/integer>`, yHotSpot As `Integer</api/data_types/integer>` |         |        |

## Method descriptions

<div id="mousecursor.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MouseCursor.Constructor

**Constructor**(image As `Picture</api/graphics/picture>`, xHotSpot As `Integer</api/data_types/integer>`, yHotSpot as `Integer</api/data_types/integer>`)

> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.
>
> </div>
>
> Creates a new cursor using the passed image. The hot spots are the x, y coordinates that the operating system uses to track the cursor's position. The upper-left corner of the cursor is position 0,0.
>
> This example creates a new cursor that uses an image that has been added to the Project.
>
> ``` xojo
> Var c As New MouseCursor(EarthAmericas, 20, 20)
> ```

## Notes

The `Cursors</api/user_interface/desktop/cursors>` module contains a library of standard mouse cursors that you can access by calling `System.Cursors<system.cursors>`.*MouseCursorName*. See the `Cursors</api/user_interface/desktop/cursors>` module for the names and descriptions of the available mouse cursors.

See the <span class="title-ref">MouseCursor</span> properties of the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class, the `Window</api/user_interface/desktop/desktopwindow>` class, and the `Control</api/user_interface/desktop/desktopuicontrol>` class. The relationships among them are as follows:

The `MouseCursor<desktopuicontrol.mousecursor>` property of a control determines the shape of the mouse pointer when the pointer enters the control's region only if the `DesktopApplication</api/user_interface/desktop/desktopapplication>` <span class="title-ref">MouseCursor</span> property is `Nil</api/language/nil>`. Similarly, the Window class's <span class="title-ref">MouseCursor</span> property determines the shape of the pointer when it enters the region of the window only if the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class's <span class="title-ref">MouseCursor</span> property is `Nil</api/language/nil>`. If the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class's <span class="title-ref">MouseCursor</span> property is not `Nil</api/language/nil>`, then it controls the shape of the pointer and a window's and any control's <span class="title-ref">MouseCursor</span> property values are ignored.

A <span class="title-ref">MouseCursor</span> can be assigned in the following ways:

- You can use a cursor in the `Cursors</api/user_interface/desktop/cursors>` module.
- You can use the constructor to create a <span class="title-ref">MouseCursor</span> from an image.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Custom cursors

The preferred way to create a custom cursor is to use the constructor. Create an image of the cursor and add it to the project file. Pass it to the constructor with the coordinates of the x,y hotspot. The latter is the point used to track the location of the cursor.

In addition, on Windows, you can still create 16 x 16 monochrome cursors with a Windows resource editor and then import the .cur files that it creates into your project.

## Sample code

The following line changes the pointer to the HandOpen cursor when the mouse enters the region of a `Canvas</api/user_interface/desktop/desktopcanvas>` control. The line is in the MouseEnter event handler.

``` xojo
Me.MouseCursor = System.Cursors.HandOpen
```

## Compatibility

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `Cursors</api/user_interface/desktop/cursors>` module; <span class="title-ref">MouseCursor</span> properties of the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class, the `Window</api/user_interface/desktop/desktopwindow>` class, and the `DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` class; `System</api/os/system>` class.

</div>
