Contents

NSCursor

A pointer (also called a cursor).

Declaration

class NSCursor

Overview

The following table shows and describes the system cursors, and indicates the class method for obtaining them:

Cursor

Description

[Image]

The arrow cursor (Arrow)

[Image]

The I-beam cursor for indicating insertion points (Ibeam)

[Image]

The cross-hair cursor (Crosshair)

[Image]

The closed-hand cursor (Closedhand)

[Image]

The open-hand cursor (Openhand)

[Image]

The pointing-hand cursor (Pointinghand)

[Image]

The resize-left cursor (Resizeleft)

[Image]

The resize-right cursor (Resizeright)

[Image]

The resize-left-and-right cursor (Resizeleftright)

[Image]

The resize-up cursor (Resizeup)

[Image]

The resize-down cursor (Resizedown)

[Image]

The resize-up-and-down cursor (Resizeupdown)

[Image]

The disappearing item cursor (Disappearingitem)

[Image]

The I-Beam text cursor for vertical layout (Ibeamcursorforverticallayout).

[Image]

The not allowed cursor (Operationnotallowed).

[Image]

The drag link cursor (Draglink).

[Image]

The drag copy cursor (Dragcopy).

[Image]

The contextual menu cursor (Contextualmenu).

In macOS 10.3 and later, cursor size is no longer limited to 16 by 16 pixels.

Cursor rectangles

In Cocoa, you can change the currently displayed cursor based on the position of the mouse over one of your views. You might use this technique to provide visual feedback about what actions the user can take with the mouse. For example, you might display one of the resize cursors whenever the mouse moves over a portion of your view that acts as a custom resizing handle. To set this up, you associate a cursor object with one or more cursor rectangles in the view.

Cursor rectangles are a specialized type of tracking rectangles, which are used to monitor the mouse location in a view. Views implement cursor rectangles using tracking rectangles but provide methods for setting and refreshing cursor rectangles that are distinct from the generic tracking rectangle interface. For information on how to set up cursor rectangles, see Mouse-Tracking and Cursor-Update Events.

Balancing cursor hiding and unhiding

Each call to hide() cursor must have a corresponding unhide() call. For example,

[NSCursor hide];
[NSCursor hide];
// ...
[NSCursor unhide];

Will result in the cursor still being hidden because the hide and unhide method invocations are not balanced. Instead you must balance the method calls, such as in the following example:

[NSCursor hide];
[NSCursor hide];
// ...
[NSCursor unhide];
[NSCursor unhide];

There are corresponding cursor hide and unhide calls, thus the cursor will become visible.

Topics

Initializing a new cursor

Setting cursor attributes

Controlling which cursor is current

Retrieving cursor instances

Constants

Deprecated

See Also

Cursors