Class

NSCursor

A pointer (also called a cursor).

Declaration

@interface NSCursor : NSObject

Overview

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

Cursor

Description

arrow cursor

The arrow cursor (arrowCursor)

I-beam cursor

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

cross-hair cursor

The cross-hair cursor (crosshairCursor)

closed-hand cursor

The closed-hand cursor (closedHandCursor)

open-hand cursor

The open-hand cursor (openHandCursor)

pointing hand cursor

The pointing-hand cursor (pointingHandCursor)

resize-left cursor

The resize-left cursor (resizeLeftCursor)

resize-right cursor

The resize-right cursor (resizeRightCursor)

resize-left-and-right cursor

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

resize-up cursor

The resize-up cursor (resizeUpCursor)

resize-down cursor

The resize-down cursor (resizeDownCursor)

resize-up-and-down cursor

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

disappearing item cursor

The disappearing item cursor (disappearingItemCursor)

disappearing item cursor

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

The not allowed cursor (operationNotAllowedCursor).

The drag link cursor (dragLinkCursor).

The drag copy cursor (dragCopyCursor).

The contextual menu cursor (contextualMenuCursor).

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

initWithImage:hotSpot:

Initializes a cursor with the given image and hot spot.

initWithImage:foregroundColorHint:backgroundColorHint:hotSpot:

Initializes the cursor with the specified image and hot spot.

Deprecated

Setting Cursor Attributes

image

The cursor’s image.

hotSpot

The position of the cursor's hot spot.

hide

Makes the current cursor invisible.

unhide

Negates an earlier call to hide by showing the current cursor.

setHiddenUntilMouseMoves:

Sets whether the cursor is hidden until the mouse moves.

Controlling Which Cursor Is Current

pop

Pops the current cursor off the top of the stack.

pop

Sends a pop message to the receiver’s class.

push

Puts the receiver on top of the cursor stack and makes it the current cursor.

set

Makes the receiver the current cursor.

mouseEntered:

Automatically sent to the receiver when the cursor enters a cursor rectangle owned by the receiver.

Deprecated
setOnMouseEntered:

Specifies whether the receiver accepts mouseEntered: events.

Deprecated
setOnMouseEntered

A Boolean value indicating whether the receiver becomes current on receiving a mouseEntered: message.

Deprecated
mouseExited:

Automatically sent to the receiver when the cursor exits a cursor rectangle owned by the receiver.

Deprecated
setOnMouseExited:

Sets whether the receiver accepts mouseExited: events.

Deprecated
setOnMouseExited

A Boolean value indicating whether the receiver becomes current when it receives a mouseExited: message.

Deprecated

Retrieving Cursor Instances

currentCursor

Returns the application’s current cursor.

currentSystemCursor

Returns the current system cursor.

arrowCursor

Returns the default cursor, the arrow cursor.

contextualMenuCursor

Returns the contextual menu system cursor.

closedHandCursor

Returns the closed-hand system cursor.

crosshairCursor

Returns the cross-hair system cursor.

disappearingItemCursor

Returns a cursor indicating that the current operation will result in a disappearing item.

dragCopyCursor

Returns a cursor indicating that the current operation will result in a copy action.

dragLinkCursor

Returns a cursor indicating that the current operation will result in a link action.

IBeamCursor

Returns a cursor that looks like a capital I with a tiny crossbeam at its middle.

openHandCursor

Returns the open-hand system cursor.

operationNotAllowedCursor

Returns the operation not allowed cursor.

pointingHandCursor

Returns the pointing-hand system cursor.

resizeDownCursor

Returns the resize-down system cursor.

resizeLeftCursor

Returns the resize-left system cursor.

resizeLeftRightCursor

Returns the resize-left-and-right system cursor.

resizeRightCursor

Returns the resize-right system cursor.

resizeUpCursor

Returns the resize-up system cursor.

resizeUpDownCursor

Returns the resize-up-and-down system cursor.

IBeamCursorForVerticalLayout

Returns the cursor for editing vertical layout text.

Constants

AppKit Versions for NSCursor Bug Fixes

The version of the AppKit framework containing a specific bug fix.

Initializers

Relationships

Inherits From

Conforms To

See Also

Cursors

NSTrackingArea

A region of a view that generates mouse-tracking and cursor-update events when the pointer is over that region.