Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Implements | |
Package | com.apple.cocoa.application |
Companion guide |
Instances of the NSCursor class manage the appearance of the cursor.
The following table shows and describes the system cursors, and indicates the static 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.
popCursor
pop
push
set
mouseEntered
setOnMouseEntered
isSetOnMouseEntered
mouseExited
setOnMouseExited
isSetOnMouseExited
currentCursor
arrowCursor
closedHandCursor
crosshairCursor
disappearingItemCursor
IBeamCursor
openHandCursor
pointingHandCursor
resizeDownCursor
resizeLeftCursor
resizeLeftRightCursor
resizeRightCursor
resizeUpCursor
resizeUpDownCursor
Creates a new cursor, assigning it a null
image and a hot spot of NSPoint.ZeroPoint
.
public NSCursor
()
Creates a cursor, assigns it newImage, and sets its hot spot to aPoint.
public NSCursor
(NSImage newImage, NSPoint aPoint)
Creates a new cursor, assigns it newImage, and sets its hot spot to aPoint.
public NSCursor
(NSImage newImage, NSColor fg, NSColor bg, NSPoint aPoint)
The foreground and background colors (fg and bg, respectively) are currently ignored.
Returns the default cursor, a slanted arrow with its hot spot at the tip.
public static NSCursor arrowCursor
()
The arrow cursor is the one you’re used to seeing over buttons, scrollers, and many other objects in the window system.
Returns the closed-hand system cursor.
public static NSCursor closedHandCursor
()
Returns the cross-hair system cursor.
public static NSCursor crosshairCursor
()
This cursor is used for situations when precise location is required (where the lines cross is the hot spot).
Returns the cursor currently displayed on the screen.
public static NSCursor currentCursor
()
Returns a cursor indicating that the current operation will result in a disappearing item (for example, when dragging an item from the dock or a toolbar).
public static NSCursor disappearingItemCursor
()
Makes the current cursor invisible.
public static 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
.
Returns a cursor that looks like a capital I with a tiny crossbeam at its middle.
public static NSCursor IBeamCursor
()
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.
Returns the open-hand system cursor.
public static NSCursor openHandCursor
()
Returns the pointing-hand system cursor.
public static NSCursor pointingHandCursor
()
The tip of the pointing finger is the hot spot.
Pops the current cursor off the top of the stack.
public static void popCursor
()
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.
public static NSCursor resizeDownCursor
()
Returns the resize-down system cursor.
public static NSCursor resizeLeftCursor
()
Returns the resize-left system cursor.
Returns the resize-left-and-right system cursor.
public static NSCursor resizeLeftRightCursor
()
Returns the resize-right system cursor.
public static NSCursor resizeRightCursor
()
Returns the resize-up system cursor.
public static NSCursor resizeUpCursor
()
Returns the resize-up-and-down system cursor.
public static NSCursor resizeUpDownCursor
()
public static void setHiddenUntilMouseMoves
(boolean flag)
If flag is true
, hides the cursor. The cursor remains invisible until one of the following occurs:
The mouse moves.
You invoke the method again, with flag set to false
.
Do not try to counter this method by invoking unhide
. The results are undefined.
Negates an earlier call to hide
by showing the current cursor.
public static void unhide
()
Returns the position of the hot spot, specified according to the cursor’s flipped coordinate system.
public NSPoint hotSpot
()
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 a constructor to create a new cursor with the new settings.
Returns the image for the receiver, or null
if none exists.
public NSImage image
()
Note that an NSCursor object is immutable: you cannot change its image after it’s created. Instead, use a constructor to create a new cursor with the new settings.
public boolean isSetOnMouseEntered
()
Returns true
if the receiver will become current when it receives a mouseEntered
message; otherwise, returns false
.
To receive such a message, the receiver must first be assigned a cursor rectangle. This assignment can be made using NSView’s addCursorRect
method. For a more complete explanation, see the class description.
public boolean isSetOnMouseExited
()
Returns true
if the receiver becomes current when it receives a mouseExited
message; otherwise, returns false
.
To receive such a message, the receiver must first be assigned a cursor rectangle. This assignment can be made using NSView’s addCursorRect
method. For a more complete explanation, see the class description.
public void mouseEntered
(NSEvent anEvent)
This message is automatically sent to the receiver when the cursor enters a tracking rectangle owned by the receiver, generating anEvent. If used after setOnMouseEntered
has been called with an argument of true
, 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”.
public void mouseExited
(NSEvent anEvent)
This message is automatically sent to the receiver when the cursor exits a tracking rectangle owned by the receiver, generating anEvent. Like mouseEntered
, it 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”.
Sends a popCursor
message to the receiver’s class.
public void pop
()
Puts the receiver on top of the cursor stack and makes it the current cursor.
public void push
()
Makes the receiver the current cursor.
public void set
()
public void setOnMouseEntered
(boolean flag)
If flag is true
, 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.
public void setOnMouseExited
(boolean flag)
If flag is true
, 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.
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)