Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.0 and later. |
Companion guide | |
Declared in | NSCursor.h |
Related sample code |
Instances of the NSCursor
class manage the appearance of the cursor.
The following table shows and describes the system cursors, and indicates the class method for obtaining them:
Cursor |
Description |
---|---|
The arrow cursor ( |
|
The I-beam cursor for indicating insertion points ( |
|
The cross-hair cursor ( |
|
The closed-hand cursor ( |
|
The open-hand cursor ( |
|
The pointing-hand cursor ( |
|
The resize-left cursor ( |
|
The resize-right cursor ( |
|
The resize-left-and-right cursor ( |
|
The resize-up cursor ( |
|
The resize-down cursor ( |
|
The resize-up-and-down cursor ( |
|
The disappearing item cursor ( |
In Mac OS X version 10.3 and later, cursor size is no longer limited to 16 by 16 pixels.
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 “Handling Tracking-Rectangle and Cursor-Update Events in Views”.
+ pop
– pop
– push
– set
– mouseEntered:
– setOnMouseEntered:
– isSetOnMouseEntered
– mouseExited:
– setOnMouseExited:
– isSetOnMouseExited
+ currentCursor
+ arrowCursor
+ closedHandCursor
+ crosshairCursor
+ disappearingItemCursor
+ IBeamCursor
+ openHandCursor
+ pointingHandCursor
+ resizeDownCursor
+ resizeLeftCursor
+ resizeLeftRightCursor
+ resizeRightCursor
+ resizeUpCursor
+ resizeUpDownCursor
Returns the default cursor, the arrow cursor.
+ (NSCursor *)arrowCursor
The default cursor, a slanted arrow with its hot spot at the tip. The arrow cursor is the one you’re used to seeing over buttons, scrollers, and many other objects in the window system.
NSCursor.h
Returns the closed-hand system cursor.
+ (NSCursor *)closedHandCursor
The closed-hand cursor.
NSCursor.h
Returns the cross-hair system cursor.
+ (NSCursor *)crosshairCursor
The cross-hair cursor. This cursor is used for situations when precise location is required (where the lines cross is the hot spot).
NSCursor.h
Returns the application’s current cursor.
+ (NSCursor *)currentCursor
The top cursor on the application’s cursor stack. This cursor may not be the visible cursor on the screen if a different application is currently active.
NSCursor.h
Returns a cursor indicating that the current operation will result in a disappearing item.
+ (NSCursor *)disappearingItemCursor
The system cursor that indicates that the current operation will result in a disappearing item (for example, when dragging an item from the dock or a toolbar).
NSCursor.h
Makes the current cursor invisible.
+ (void)hide
If another cursor becomes current, that cursor will be invisible, too. It will remain invisible until you invoke the unhide
method.
hide
overrides setHiddenUntilMouseMoves:
.
NSCursor.h
Returns a cursor that looks like a capital I with a tiny crossbeam at its middle.
+ (NSCursor *)IBeamCursor
The I-beam cursor. This is the cursor that you’re used to seeing over editable or selectable text. The I-beam cursor’s default hot spot is where the crossbeam intersects the I.
NSCursor.h
Returns the open-hand system cursor.
+ (NSCursor *)openHandCursor
The open-hand cursor.
NSCursor.h
Returns the pointing-hand system cursor.
+ (NSCursor *)pointingHandCursor
The pointing-hand cursor. The tip of the pointing finger is the hot spot.
NSCursor.h
Pops the current cursor off the top of the stack.
+ (void)pop
The new object on the top of the stack becomes the current cursor. If the current cursor is the only cursor on the stack, this method does nothing.
NSCursor.h
Returns the resize-down system cursor.
+ (NSCursor *)resizeDownCursor
The resize-down cursor. This cursor is used when moving or resizing an object to indicate that the user can move only in the indicated direction.
NSCursor.h
Returns the resize-left system cursor.
+ (NSCursor *)resizeLeftCursor
The resize-left cursor. This cursor is used when moving or resizing an object to indicate that the user can move only in the indicated direction.
NSCursor.h
Returns the resize-left-and-right system cursor.
+ (NSCursor *)resizeLeftRightCursor
The resize-left-and-right cursor. This cursor is used when moving or resizing an object and the object can be moved left or right.
NSCursor.h
Returns the resize-right system cursor.
+ (NSCursor *)resizeRightCursor
The resize-right cursor. This cursor is used when moving or resizing an object to indicate that the user can move only in the indicated direction.
NSCursor.h
Returns the resize-up system cursor.
+ (NSCursor *)resizeUpCursor
The resize-up cursor. This cursor is used when moving or resizing an object to indicate that the user can move only in the indicated direction.
NSCursor.h
Returns the resize-up-and-down system cursor.
+ (NSCursor *)resizeUpDownCursor
The resize-up-and-down cursor. This cursor is used when moving or resizing an object and the object can be moved up or down.
NSCursor.h
Sets whether the cursor is hidden until the mouse moves.
+ (void)setHiddenUntilMouseMoves:(BOOL)flag
YES
to hide the cursor until one of the following occurs:
The mouse moves.
You invoke the method again, with flag set to NO
.
Do not try to counter this method by invoking unhide
. The results are undefined.
NSCursor.h
Negates an earlier call to hide
by showing the current cursor.
+ (void)unhide
NSCursor.h
Returns the position of the cursor's hot spot.
- (NSPoint)hotSpot
The point describing the position of the hot spot, specified according to the cursor’s flipped coordinate system.
For a more complete explanation, see the class description.
Note that an NSCursor
object is immutable: you cannot change its hot spot after it’s created. Instead, use initWithImage:hotSpot:
to create a new cursor with the new settings.
NSCursor.h
Returns the receiver's image.
- (NSImage *)image
The cursor image or nil
if none exists
Note that an NSCursor
object is immutable: you cannot change its image after it’s created. Instead, use initWithImage:hotSpot:
to create a new cursor with the new settings.
NSCursor.h
Initializes the cursor with the specified image and hot spot.
- (id)initWithImage:(NSImage *)newImage foregroundColorHint:(NSColor *)fg backgroundColorHint:(NSColor *)bg hotSpot:(NSPoint)hotSpot
The image to assign to the cursor.
The foreground color. This is currently ignored.
The background color. This is currently ignored.
The point to assign as the cursor's hot spot.
The initialized cursor object.
NSCursor.h
Initializes a cursor with the given image and hot spot.
- (id)initWithImage:(NSImage *)newImage hotSpot:(NSPoint)aPoint
The image to assign to the cursor.
The point to set as the cursor's hot spot.
An initialized cursor object.
This method is the designated initializer for the class.
NSCursor.h
Returns a Boolean value indicating whether the receiver becomes current on receiving a mouseEntered:
message.
- (BOOL)isSetOnMouseEntered
YES
if the receiver will become current when it receives a mouseEntered:
message; otherwise, NO
.
To receive such a message, the receiver must first be assigned a cursor rectangle. This assignment can be made using the NSView
method addCursorRect:cursor:
. For a more complete explanation, see the class description.
NSCursor.h
Returns a Boolean value indicating whether the receiver becomes current when it receives a mouseExited:
message.
- (BOOL)isSetOnMouseExited
YES
if the receiver becomes current when it receives a mouseExited:
message; otherwise, NO
.
To receive such a message, the receiver must first be assigned a cursor rectangle. This assignment can be made using the NSView
method addCursorRect:cursor:
. For a more complete explanation, see the class description.
NSCursor.h
Automatically sent to the receiver when the cursor enters a cursor rectangle owned by the receiver.
- (void)mouseEntered:(NSEvent *)anEvent
The event generated when the cursor enters the cursor rectangle.
If used after setOnMouseEntered:
has been called with an argument of YES
, mouseEntered:
can make the receiver the current cursor.
In your programs, you won’t invoke mouseEntered:
explicitly. It’s only included in the class interface so you can override it.
For a more complete explanation, see “Handling Tracking-Rectangle and Cursor-Update Events in Views” and the NSView
method addTrackingRect:owner:userData:assumeInside:
.
NSCursor.h
Automatically sent to the receiver when the cursor exits a cursor rectangle owned by the receiver.
- (void)mouseExited:(NSEvent *)anEvent
The event generated when the cursor exits the cursor rectangle.
Like mouseEntered:
, this message is part of the class interface only so you can override it.
For a more complete explanation, see “Handling Tracking-Rectangle and Cursor-Update Events in Views” and the NSView method addTrackingRect:owner:userData:assumeInside:
.
NSCursor.h
Sends a pop
message to the receiver’s class.
- (void)pop
NSCursor.h
Puts the receiver on top of the cursor stack and makes it the current cursor.
- (void)push
NSCursor.h
Makes the receiver the current cursor.
- (void)set
NSCursor.h
Specifies whether the receiver accepts mouseEntered: events.
- (void)setOnMouseEntered:(BOOL)flag
YES
if the receiver accepts future mouseEntered:
event messages; otherwise it ignores them.
Accepting mouseEntered:
event messages allows the cursor to be made the current cursor when the cursor enters a view’s cursor rectangle.
NSCursor.h
Sets whether the receiver accepts mouseExited:
events.
- (void)setOnMouseExited:(BOOL)flag
YES
if the receiver accepts future mouseExited:
event messages; otherwise it ignores them.
Accepting mouseExited:
event messages allows the cursor to be made the current cursor when the cursor exits a view’s cursor rectangle.
NSCursor.h
The version of the AppKit framework containing a specific bug fix.
#define NSAppKitVersionNumberWithCursorSizeSupport 682.0
NSAppKitVersionNumberWithCursorSizeSupport
The specific version of the AppKit framework that introduced support for cursors larger than 16 x 16 pixels in size. Developers should not need to use this constant unless they are writing applications for Mac OS X v10.2 and earlier.
Available in Mac OS X v10.3 and later.
Declared in NSCursor.h
.
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)