MouseCursor

From Xojo Documentation

Class (inherits from Object)

Used to specify the appearance of the pointer.

Constructors

Constructor(image as Picture, xHotSpot as Integer, yHotSpot as Integer)


Notes

The Cursors module contains a library of standard mouse cursors that you can access by calling System.Cursors.MouseCursorName. See the Cursors module for the names and descriptions of the available mouse cursors.

See the MouseCursor properties of the Application class, the Window class, and the Control class. The relationships among them are as follows:

The MouseCursor property of a control determines the shape of the mouse pointer when the pointer enters the control's region only if the Application MouseCursor property is Nil. Similarly, the Window class's MouseCursor property determines the shape of the pointer when it enters the region of the window only if the Application class's MouseCursor property is Nil. If the Application class’s MouseCursor property is not Nil, then it controls the shape of the pointer and a window's and any control's MouseCursor property values are ignored.

A MouseCursor can be assigned in the following ways:

  • You can use a cursor in the Cursors module.
  • You can use the constructor to create a MouseCursor from an image.

Custom Cursors

The preferred way to create a custom cursor is to use the constructor. Simply 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.

On Windows, you can create cursors with a Windows resource editor and then import the .cur files that it creates into your project. Currently, only 16 x 16 monochrome cursors are supported.

Examples

The following line changes the pointer to the HandOpen cursor when the mouse enters the region of a Canvas control. The line is in the MouseEnter event handler.

Me.MouseCursor = System.Cursors.HandOpen

Assign a custom cursor to the MouseCursor property of the Application or a Window in the same way.

See Also

Cursors module; MouseCursor properties of the Application class, the Window class, and the Control class; System class.