NSStatusItem Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSStatusItem.h |
Overview
The NSStatusItem class represents the individual elements displayed within an NSStatusBar object. Instances are created by the NSStatusBar method statusItemWithLength:, which automatically adds the new status item to the status bar. The appearance and behavior of the status item are then set using the various NSStatusItem methods, such as setTitle: and setAction:.
Tasks
Getting the Item’s Status Bar
Configuring the Status Item’s Appearance
-
– setTitle: -
– title -
– setAttributedTitle: -
– attributedTitle -
– setImage: -
– image -
– setAlternateImage: -
– alternateImage -
– setLength: -
– length -
– setHighlightMode: -
– highlightMode -
– setToolTip: -
– toolTip
Managing the Status Item’s Behavior
-
– setEnabled: -
– isEnabled -
– setTarget: -
– target -
– setAction: -
– action -
– setDoubleAction: -
– doubleAction -
– sendActionOn: -
– setMenu: -
– menu -
– popUpStatusItemMenu:
Managing a Custom View
Drawing a Status Item
Instance Methods
action
Returns the selector that is sent to the receiver’s target when the user clicks the receiver.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.halternateImage
Returns the alternate image that is displayed when a status bar item is highlighted.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSStatusItem.hattributedTitle
Returns the attributed string that is displayed at the receiver’s position in the status bar
Discussion
.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hdoubleAction
Returns the selector that is sent to the receiver’s target when the user double-clicks the receiver.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSStatusItem.hdrawStatusBarBackgroundInRect:withHighlight:
Draws the menu background pattern for a custom status-bar item in regular or highlight pattern.
Parameters
- rect
A rectangle defining the area of a custom status-bar item.
- highlight
YESto draw the background pattern in the standard highlight pattern, NO to not highlight the pattern..
Discussion
You can use this method to help a custom status-bar item emulate the behavior of a standard item.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSStatusItem.hhighlightMode
Returns whether the receiver is highlighted when clicked.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.himage
Returns the image that is displayed at the receiver’s position in the status bar.
Discussion
Returns nil if an image has not been set.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hisEnabled
Returns whether the receiver is enabled and responding to clicks.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hlength
Returns the amount of space allocated to the receiver within its status bar.
Discussion
If the status bar is horizontal, the return value is the width of the status item. Besides a physical length, the return value may be NSSquareStatusItemLength or NSVariableStatusItemLength (see NSStatusBar “Constants”), if the status item size is either determined by the status bar thickness or allowed to vary according to the status item’s true size, respectively.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setLength: -
statusItemWithLength:(NSStatusBar)
Declared In
NSStatusItem.hmenu
Returns the drop-down menu that is displayed when the receiver is clicked.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hpopUpStatusItemMenu:
Displays a menu under a custom status bar item.
Parameters
- menu
The
NSMenuobject to display.
Discussion
You can use this method to cause a popup menu to appear under a custom status bar item when the user clicks the item. Note that the view of the receiver must exist (that is, it must not be nil).
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSStatusItem.hsendActionOn:
Sets the conditions on which the receiver sends action messages to its target.
Parameters
- mask
Takes one or more of the following bit masks described in “Constants” section of the
NSEventclass reference:NSLeftMouseUpMask,NSLeftMouseDownMask,NSLeftMouseDraggedMask, andNSPeriodicMask. Bitwise-OR multiple bit masks.
Return Value
A bit mask containing the previous settings. This bit mask uses the same values as specified in the mask parameter.
Availability
- Available in OS X v10.0 and later.
Declared In
NSStatusItem.hsetAction:
Sets the selector that is sent to the receiver’s target when the receiver is clicked.
Discussion
If the receiver has a menu set, action is not sent to the target when the receiver is clicked; instead, the click causes the menu to appear.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hsetAlternateImage:
Sets an alternate image to be displayed when a status bar item is highlighted.
Availability
- Available in OS X v10.3 and later.
See Also
Declared In
NSStatusItem.hsetAttributedTitle:
Sets the attributed string that is displayed at the receiver’s position in the status bar.
Discussion
If an image is also set, the title appears to the right of the image.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hsetDoubleAction:
Sets the selector that is sent to the receiver’s target when the receiver is double-clicked.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSStatusItem.hsetEnabled:
Sets whether the receiver is enabled to respond to clicks.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hsetHighlightMode:
Sets whether the receiver is highlighted when it is clicked.
Discussion
The default is NO, which means the receiver isn’t highlighted when it is clicked.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hsetImage:
Sets the image that is displayed at the receiver’s position in the status bar to image.
Discussion
If a title is also set, the image appears to the left of the title.
Availability
- Available in OS X v10.0 and later.
Declared In
NSStatusItem.hsetLength:
Sets the amount of space in the status bar that should be allocated to the receiver.
Parameters
- len
If the status bar is horizontal, len is the horizontal space to allocate. In addition to a fixed length, len can be
NSSquareStatusItemLengthorNSVariableStatusItemLengthto allow the status bar to allocate (and adjust) the space according to either the status bar’s thickness or the status item’s true size.
Availability
- Available in OS X v10.0 and later.
See Also
-
– length -
– statusItemWithLength:(NSStatusBar)
Declared In
NSStatusItem.hsetMenu:
Sets the pull-down menu that is displayed when the receiver is clicked.
Parameters
- menu
The
NSMenuobject to display.
Discussion
When set, the receiver’s single click action behavior is not used. The menu can be removed by setting menu to nil.
Availability
- Available in OS X v10.0 and later.
Declared In
NSStatusItem.hsetTarget:
Sets the target object to which the receiver’s action message is sent when the receiver is clicked.
Discussion
If the receiver has a menu set, the action is not sent to target when the receiver is clicked; instead, the click causes the menu to appear.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hsetTitle:
Sets the string that is displayed at the receiver’s position in the status bar.
Discussion
If an image is also set, the title appears to the right of the image.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hsetToolTip:
Sets the tool tip string that is displayed when the cursor pauses over the receiver.
Parameters
- toolTip
A string that functions as the title of the status item.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hsetView:
Sets the custom view that is displayed at the receiver’s position in the status bar.
Parameters
- view
The
NSViewobject representing the custom view.
Discussion
Setting a custom view overrides all the other appearance and behavior settings defined by NSStatusItem. The custom view is responsible for drawing itself and providing its own behaviors, such as processing mouse clicks and sending action messages.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hstatusBar
Returns the status bar in which the receiver is displayed.
Availability
- Available in OS X v10.0 and later.
Declared In
NSStatusItem.htarget
Returns the target to which the receiver’s action message is sent when the user clicks the receiver.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.htitle
Returns the string that is displayed at the receiver’s position in the status bar.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.htoolTip
Returns the tool tip string that is displayed when the cursor pauses over the receiver.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.hview
Returns the custom view that is displayed at the receiver’s position in the status bar.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSStatusItem.h© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-03-05)