mousecursor.newCursor()


Type Function

Return value Cursor

See also mousecursor.*


Overview

Creates a cursor instance.

The cursor is not visible by defualt, call cursor:show() to make it visible.

You can either use standard system cursors like crosshair or pointing hand, or load a custom image to be used as a cursor.

If you are using several cursors in your app, there is no need to create a new instance each time mouse enters a specified area. Create all cursor instances at once and later switch between them by calling cursor:show().

Custom cursor image format

  • macOS: PNG image.
  • Windows: CUR or ANI file.

Syntax

This function accepts either a name string argument for the standard system cursor, or a params table for a custom image cursor.

mousecursor.newCursor(name | params)

name required

String. Name of a standard system mouse cursor. See the “Standard cursors” section for the list of system cursors.

params required

Table. Contains parameters to make a cursor from a custom image.

Parameter reference

The params table includes parameters for the call.

filename required

String. Custom cursor image filename. PMG on macOS, CUR or ANI on Windows.

baseDir optional

Constant Image base directory. Default is system.ResourceDirectory.

x optional macOS only

Integer. X coordinate of the cursor’s tip point in the image. Default is 0.

y optional macOS only

Integer. Y coordinate of the cursor’s tip point in the image. Default is 0.

Standard cursors

Universal

  • 'arrow'
  • 'crosshair'
  • 'i beam'
  • 'pointing hand'
  • 'operation not allowed'
  • 'resize left right'
  • 'resize up'
  • 'resize up down'

macOS

  • 'contextual menu'
  • 'closed hand'
  • 'disappearing item'
  • 'drag copy'
  • 'drag link'
  • 'open hand'
  • 'resize down'
  • 'resize left'
  • 'resize right'
  • 'i beam vertical'

Windows

  • 'small hourglass'
  • 'help'
  • 'resize all'
  • 'resize up right'
  • 'resize up left'
  • 'hourglass'