| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSButtonCell.h |
| Related sample code |
The NSButtonCell class is a subclass of NSActionCell used to implement the user interfaces of push buttons, checkboxes (switches), and radio buttons. It can also be used for any other region of a view that’s designed to send a message to a target when clicked. The NSButton subclass of NSControl uses a single NSButtonCell.
The NSButtonCell class implements the user interface of NSButton.
Setting the integer, float, double, or object value of an NSButtonCell object results in a call to setState: with the value converted to integer. In the case of setObjectValue:, nil is equivalent to 0, and a non-nil object that doesn't respond to intValue sets the state to 1. Otherwise, the state is set to the object's intValue. Similarly, querying the integer, float, double, or object value of an NSButtonCell returns the current state in the requested representation. In the case of objectValue, this is an NSNumber containing YES for on, NO for off, and integer value -1 for the mixed state.
For more information on the behavior of NSButtonCell, see the NSButton and NSMatrix class specifications, and Button Programming Topics for Cocoa.
In its implementation of the compare: method (declared in NSCell), NSButtonCell raises an NSBadComparisonException if the otherCell argument is not of the NSButtonCell class.
– alternateMnemonic
– alternateMnemonicLocation
– alternateTitle
– attributedAlternateTitle
– attributedTitle
– setAlternateMnemonicLocation:
– setAlternateTitle:
– setAlternateTitleWithMnemonic:
– setAttributedAlternateTitle:
– setAttributedTitle:
– setFont:
– setTitle:
– setTitleWithMnemonic:
– title
– alternateImage
– imagePosition
– setAlternateImage:
– setImagePosition:
– imageScaling
– setImageScaling:
– keyEquivalent
– keyEquivalentFont
– keyEquivalentModifierMask
– setKeyEquivalent:
– setKeyEquivalentModifierMask:
– setKeyEquivalentFont:
– setKeyEquivalentFont:size:
– backgroundColor
– setBackgroundColor:
– bezelStyle
– setBezelStyle:
– gradientType
– setGradientType:
– imageDimsWhenDisabled
– setImageDimsWhenDisabled:
– isOpaque
– isTransparent
– setTransparent:
– showsBorderOnlyWhileMouseInside
– setShowsBorderOnlyWhileMouseInside:
Returns the image the button displays in its alternate state.
- (NSImage *)alternateImage
The image displayed by the button when it's in its alternate state, or nil if there is no alternate image.
Note that some button types don’t display an alternate image. Buttons don’t display images by default.
NSButtonCell.hReturns the character in the alternate title that’s marked as the “keyboard mnemonic.”
- (NSString *)alternateMnemonic
The character in the alternate title (the title displayed on the receiver when it's in its alternate state) marked as the "keyboard mnemonic."
Mnemonics are not supported in Mac OS X.
NSButtonCell.hReturns an unsigned integer indicating the character in the alternate title that’s marked as the “keyboard mnemonic.”
- (NSUInteger)alternateMnemonicLocation
An unsigned integer indicating the character in the alternate title (the title displayed on the receiver when it’s in its alternate state) that’s marked as the “keyboard mnemonic.” If the alternate title doesn’t have a keyboard mnemonic, returns NSNotFound.
Mnemonics are not supported in Mac OS X.
– setAlternateMnemonicLocation:– alternateMnemonic– setAlternateTitleWithMnemonic:– mnemonicLocation (NSCell)NSButtonCell.hReturns the string displayed by the button when it’s in its alternate state.
- (NSString *)alternateTitle
The string that appears on the button when it's in its alternate state, or the empty string if the receiver doesn’t display an alternate title.
Note that some button types don’t display an alternate title. By default, a button’s alternate title is “Button.”
NSButtonCell.hReturns the title displayed by the button when it’s in its alternate state, as an attributed string.
- (NSAttributedString *)attributedAlternateTitle
The attributed string that appears on the button when it's in its alternate state, or the empty string if the receiver doesn’t display an alternate title.
Note that some button types don’t display an alternate title. By default, a button’s alternate title is “Button.”
NSButtonCell.hReturns the title displayed by the button when it’s in its normal state as an attributed string.
- (NSAttributedString *)attributedTitle
The attributes string that appears on the button when it's in its normal state, or an empty attributed string if the receiver doesn’t display a title.
A button’s title is always displayed if the button doesn’t use its alternate contents for highlighting or displaying the alternate state. By default, a button’s title is “Button.”
NSButtonCell.hReturns the background color of the receiver.
- (NSColor *)backgroundColor
The receiver’s background color.
The background color is used only when drawing borderless buttons.
NSButtonCell.hReturns the appearance of the receiver’s border.
- (NSBezelStyle)bezelStyle
A constant specifying the bezel style used by the button. See “Bezel Styles” for a list of possible values.
NSButtonCell.hDraws the border of the button using the current bezel style.
- (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView
The bounding rectangle of the button.
The control being drawn.
This method is called automatically when the button is redrawn; you should not call it directly.
NSButtonCell.hDraws the image associated with the button’s current state.
- (void)drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView *)controlView
The image associated with the button's current state.
The bounding rectangle of the button.
The control being drawn.
This method is called automatically when the button is redrawn; you should not call it directly.
You specify the primary and alternate images for the button using Interface Builder.
NSButtonCell.hDraws the button’s title centered vertically in a specified rectangle.
- (NSRect)drawTitle:(NSAttributedString *)title withFrame:(NSRect)frame inView:(NSView *)controlView
The title of the button.
The rectangle in which to draw the title.
The control being drawn.
The bounding rectangle for the text of the title.
This method is called automatically when the button is redrawn; you should not call it directly.
NSButtonCell.hReturns by reference the delay and interval periods for a continuous button.
- (void)getPeriodicDelay:(float *)delay interval:(float *)interval
On return, the amount of time (in seconds) that the button will pause before starting to periodically send action messages to the target object. Default values are taken from the user's defaults (60 seconds maximum); if the user hasn't specified a default value, this defaults to 0.4 seconds.
On return, the amount of time (in seconds) between each action message. Default values are taken from the user's defaults (60 seconds maximum); if the user hasn't specified a default value, this defaults to 0.075 seconds.
– isContinuous– isContinuous (NSCell)NSButtonCell.hReturns the gradient of the receiver’s border.
- (NSGradientType)gradientType
A constant specifying the gradient used for the button's border. See “Gradient Types” for a list of possible values.
NSButtonCell.hReturns flags indicating how the button highlights when it receives a mouse-down event.
- (NSInteger)highlightsBy
The logical OR of flags that indicate the way the receiver highlights when it receivers a mouse-down event. See the “Constants” section of NSCell for the list of flags.
NSButtonCell.h
Returns a Boolean value that indicates whether the receiver’s image and text appear “dim” when the receiver is disabled.
- (BOOL)imageDimsWhenDisabled
YES if the button's image and text are dimmed when the button is disabled, otherwise NO.
By default, all button types except NSSwitchButton and NSRadioButton do dim when disabled. When buttons of type NSSwitchButton and NSRadioButton are disabled, only the associated text dims.
NSButtonCell.hReturns the position of the receiver’s image relative to its title.
- (NSCellImagePosition)imagePosition
The position of the button's image. This is one of the image positions described in the “Constants” section of NSCell.
If the title is above, below, or overlapping the image, or if there is no image, the text is horizontally centered within the button.
NSButtonCell.hReturns the scale factor for the receiver’s image.
- (NSImageScaling)imageScaling
The scale factor for the receiver’s image.
NSButtonCell.hReturns a Boolean value that indicates whether the receiver is opaque.
- (BOOL)isOpaque
YES if the receiver draws over every pixel in its frame, otherwise NO.
A button cell is opaque only if it isn’t transparent and if it has a border.
NSButtonCell.hReturns a Boolean value that indicates whether the receiver is transparent.
- (BOOL)isTransparent
YES if the receiver is transparent, NO otherwise.
A transparent button never draws itself, but it receives mouse-down events and tracks the mouse properly.
NSButtonCell.hReturns the receiver's key-equivalent character.
- (NSString *)keyEquivalent
The string containing the key equivalent character of the button, or the empty string if one hasn't been defined.
Buttons don't have a default key equivalent.
NSButtonCell.hReturns the font used to draw the key equivalent.
- (NSFont *)keyEquivalentFont
The font object describing the font used to draw the button's key equivalent, or nil if the receiver doesn’t have a key equivalent.
The default font is the same as that used to draw the title.
NSButtonCell.hReturns the mask identifying the modifier keys for the button's key equivalent.
- (NSUInteger)keyEquivalentModifierMask
A mask indicating the modifier keys that are applied to the receiver's key equivalent.
Mask bits are defined in NSEvent.h. The only mask bits relevant in button key-equivalent modifier masks are NSControlKeyMask, NSAlternateKeyMask, and NSCommandKeyMask bits.
NSButtonCell.hDraws the receiver’s border.
- (void)mouseEntered:(NSEvent *)event
The event object generated by the mouse movement.
This method is called only when the cursor moves onto the receiver and showsBorderOnlyWhileMouseInside returns YES.
NSButtonCell.hErases the receiver’s border.
- (void)mouseExited:(NSEvent *)event
The event object generated by the mouse movement.
This method is called only when the cursor moves off the receiver and showsBorderOnlyWhileMouseInside returns YES.
NSButtonCell.hSimulates the user clicking the receiver with the cursor.
- (void)performClick:(id)sender
The sender of the message.
This method essentially highlights the button, sends the button’s action message to the target object, and then unhighlights the button. If an exception is raised while the target object is processing the action message, the button is unhighlighted before the exception is propagated out of performClick:.
NSButtonCell.hSets the image the button displays in its alternate state and, if necessary, redraws its contents.
- (void)setAlternateImage:(NSImage *)image
The image displayed by the button when it's in its alternate state.
Note that some button types don’t display an alternate image.
– alternateImage– setButtonType:– setImage: (NSCell)NSButtonCell.hSets the character in the alternate title that should be the “keyboard mnemonic.”
- (void)setAlternateMnemonicLocation:(NSUInteger)location
An unsigned integer indicating the character in the alternate title that should be marked as the "keyboard mnemonic." If you don’t want the alternate title to have a keyboard mnemonic, specify a location of NSNotFound.
Mnemonics are not supported in Mac OS X.
The setAlternateMnemonicLocation: method doesn’t cause the button cell to be redisplayed.
NSButtonCell.hSets the title the button displays when it’s in its alternate state.
- (void)setAlternateTitle:(NSString *)aString
The string to set as the button's title when it's in its alternate state.
Note that some button types don’t display an alternate title.
– alternateTitle– setAlternateMnemonicLocation:– setAlternateTitleWithMnemonic:– setTitle:– setButtonType:– setFont:NSButtonCell.hSets the title the button displays when it’s in its alternate state to the given string with an embedded mnemonic.
- (void)setAlternateTitleWithMnemonic:(NSString *)aString
The string to set as the button's alternate title, taking into account the fact that an embedded “&” character is not a literal but instead marks the alternate state’s “keyboard mnemonic.”
Mnemonics are not supported in Mac OS X.
If necessary, setAlternateTitleWithMnemonic: redraws the button cell. Note that some button types don’t display an alternate title.
NSButtonCell.hSets the string the button displays when it’s in its alternate state to the given attributed string.
- (void)setAttributedAlternateTitle:(NSAttributedString *)aString
The attributed string to set as the button's alternate title.
Note that some button types don’t display an alternate title.
Graphics attributes that are set on the cell (backgroundColor, alignment, font, etc.) are overriden when corresponding properties are set for the attributed string.
– attributedAlternateTitle– setAlternateMnemonicLocation:– setAlternateTitleWithMnemonic:– setAttributedTitle:– setButtonType:– setFont:NSButtonCell.hSets the string the button displays when it’s in its normal state to the given attributed string and redraws the button.
- (void)setAttributedTitle:(NSAttributedString *)aString
The attributed string to set as the button's title.
The title is always shown on buttons that don’t use their alternate contents when highlighting or displaying their alternate state.
Graphics attributes configured for the cell (backgroundColor, alignment, font, etc.) are overriden when corresponding properties are set for the attributed string.
– attributedTitle– setAttributedAlternateTitle:– setButtonType:– setFont:– setMnemonicLocation: (NSCell)NSButtonCell.hSets the background color of the receiver.
- (void)setBackgroundColor:(NSColor *)color
The color to use for the receiver’s background.
The background color is used only when drawing borderless buttons.
NSButtonCell.hSets the appearance of the border, if the receiver has one.
- (void)setBezelStyle:(NSBezelStyle)bezelStyle
A constant specifying the bezel style to use for the button. This must be one of the values specified in “Bezel Styles.”
If the receiver is not bordered, the bezel style is ignored.
A button uses shading to look like it’s sticking out or pushed in. You can set the shading with setGradientType:.
NSButtonCell.hSets how the receiver highlights while pressed and how it shows its state.
- (void)setButtonType:(NSButtonType)aType
A constant specifying the type of button. This can be one of the constants defined in “Button Types.”
setButtonType: redisplays the receiver before returning.
The types available are for the most common button types, which are also accessible in Interface Builder; you can configure different behavior with the setHighlightsBy: and setShowsStateBy: methods.
Note that there is no -buttonType method. The set method sets various button properties that together establish the behavior of the type.
– setAlternateImage:– setImage: (NSCell)NSButtonCell.hSets the font used to display the button's title and alternate title.
- (void)setFont:(NSFont *)fontObj
The font object specifying the font to use.
This method does nothing if the receiver has no title or alternate title.
If the button cell has a key equivalent, its font is not changed, but the key equivalent’s font size is changed to match the new title font.
NSButtonCell.hSets the type of gradient to use for the receiver.
- (void)setGradientType:(NSGradientType)gradientType
A constant specifying the gradient to use for the button's border. This can be one of the constants defined in “Gradient Types.”
If the receiver has no border, this method has no effect on its appearance. A concave gradient is darkest in the top-left corner; a convex gradient is darkest in the bottom-right corner. Weak versus strong is how much contrast exists between the colors used in opposite corners.
NSButtonCell.hSets the way the receiver highlights itself while pressed.
- (void)setHighlightsBy:(NSInteger)aType
The logical OR of one or more of the cell masks described in the “Constants” section of NSCell.
If both NSChangeGrayCellMask and NSChangeBackgroundCellMask are specified, both are recorded, but which behavior is used depends on the button cell’s image. If the button has no image, or if the image has no alpha (transparency) data, NSChangeGrayCellMask is used. If the image does have alpha data, NSChangeBackgroundCellMask is used; this arrangement allows the color swap of the background to show through the image’s transparent pixels.
NSButtonCell.hSets whether the receiver’s image appears “dim” when the button cell is disabled.
- (void)setImageDimsWhenDisabled:(BOOL)flag
YES to indicate that the button's image should dim when the button is disabled.
By default, all button types except NSSwitchButton and NSRadioButton do dim when disabled. When NSSwitchButtons and NSRadioButtons are disabled, only the associated text dims. The default setting for this condition is reasserted whenever you invoke setButtonType:, so be sure to specify the button cell’s type before you invoke setImageDimsWhenDisabled:.
NSButtonCell.hSets the position of the receiver’s image relative to its title.
- (void)setImagePosition:(NSCellImagePosition)aPosition
A constant specifying the position of the button's image. See the “Constants” section of NSCell for a listing of possible values.
NSButtonCell.hSets the scale factor for the receiver’s image.
- (void)setImageScaling:(NSImageScaling)scaling
The scale factor for the receiver’s image.
NSButtonCell.hSets the key equivalent character of the receiver.
- (void)setKeyEquivalent:(NSString *)aKeyEquivalent
The key equivalent character.
This method redraws the receiver’s inside if it displays a key equivalent instead of an image. The key equivalent isn’t displayed if the image position is set to NSNoImage, NSImageOnly, or NSImageOverlaps; that is, the button must display both its title and its “image” (the key equivalent in this case), and they must not overlap.
To display a key equivalent on a button, set the image and alternate image to nil, then set the key equivalent, then set the image position.
– keyEquivalent– setAlternateImage:– setImagePosition:– setKeyEquivalentFont:– setImage: (NSCell)NSButtonCell.hSets the font used to draw the key equivalent and redisplays the receiver if necessary.
- (void)setKeyEquivalentFont:(NSFont *)fontObj
The font object specifying the font to use for the receiver's key equivalent.
This method does nothing if the receiver doesn’t have a key equivalent associated with it.
The default font is the same as that used to draw the title.
NSButtonCell.hSets by name and size of the font used to draw the key equivalent.
- (void)setKeyEquivalentFont:(NSString *)fontName size:(CGFloat)fontSize
The name of the font to use to draw the key equivalent.
The font size to use to draw the key equivalent.
This method redisplays the receiver if necessary. It does nothing if the receiver doesn’t have a key equivalent associated with it. The default font is the same as that used to draw the title.
NSButtonCell.hSets the mask identifying the modifier keys to use with the button's key equivalent.
- (void)setKeyEquivalentModifierMask:(NSUInteger)mask
The mask indicating the modifier keys to be applied to the receiver's key equivalent.
Mask bits are defined in NSEvent.h. The only mask bits relevant in button key-equivalent modifier masks are NSControlKeyMask, NSAlternateKeyMask, and NSCommandKeyMask.
NSButtonCell.hSets the message delay and interval for the receiver.
- (void)setPeriodicDelay:(float)delay interval:(float)interval
The amount of time (in seconds) that a continuous button will pause before starting to periodically send action messages to the target object.
The maximum value is 60.0 seconds; if a larger value is supplied, it’s ignored, and 60.0 seconds is used.
The amount of time (in seconds) between each action message.
The maximum value is 60.0 seconds; if a larger value is supplied, it’s ignored, and 60.0 seconds is used.
These values are used if the receiver is configured (by a setContinuous: message) to continuously send the action message to the target object while tracking the mouse.
– setContinuous: (NSCell)NSButtonCell.hSets whether the receiver’s border is displayed only when the cursor is over the button.
- (void)setShowsBorderOnlyWhileMouseInside:(BOOL)show
YES to display the button's border only when the cursor is within the receiver’s border and the button is active. NO to continue to display the border when the cursor is outside button’s bounds.
NSButtonCell.hSets the way the receiver indicates its alternate state.
- (void)setShowsStateBy:(NSInteger)aType
The logical OR of one or more of the cell masks described in the “Constants” section of NSCell.
If both NSChangeGrayCellMask and NSChangeBackgroundCellMask are specified, both are recorded, but the actual behavior depends on the button cell’s image. If the button has no image, or if the image has no alpha (transparency) data, NSChangeGrayCellMask is used. If the image exists and has alpha data, NSChangeBackgroundCellMask is used; this arrangement allows the color swap of the background to show through the image’s transparent pixels.
NSButtonCell.hSets the sound that’s played when the user presses the receiver.
- (void)setSound:(NSSound *)aSound
The sound to play when the button is pressed.
The sound is played during a mouse-down event, such as NSLeftMouseDown.
NSButtonCell.hSets the title the button displays when in its normal state and, if necessary, redraws the receiver’s contents.
- (void)setTitle:(NSString *)aString
The string to set as the button's title.
The title is always shown on buttons that don’t use their alternate contents when highlighting or displaying their alternate state.
NSButtonCell.hSets the title the button displays when it’s in its normal state to the given string with an embedded mnemonic.
- (void)setTitleWithMnemonic:(NSString *)aString
The string to set as the button's title, taking into account the fact that an embedded “&” character is not a literal but instead marks the alternate state’s “keyboard mnemonic.” This title is always shown on buttons that don’t use their alternate contents when highlighting or displaying their alternate state.
If necessary, setTitleWithMnemonic: redraws the button cell. Mnemonics are not supported in Mac OS X.
– setAlternateTitleWithMnemonic:– setTitleWithMnemonic: (NSCell)– setMnemonicLocation: (NSCell)NSButtonCell.h
Sets whether the receiver is transparent.
- (void)setTransparent:(BOOL)flag
YES to make the button cell transparent.
This method redraws the receiver if necessary. A transparent button tracks the mouse and sends its action, but doesn’t draw. A transparent button is useful for sensitizing an area on the screen so that an action gets sent to a target when the area receives a mouse click.
NSButtonCell.hReturns a Boolean value indicating whether the button displays its border only when the cursor is over it.
- (BOOL)showsBorderOnlyWhileMouseInside
YES if the receiver’s border is displayed only when the cursor is over the button and the button is active.
By default, this method returns NO.
NSButtonCell.hReturns the flags indicating how the button cell shows its alternate state.
- (NSInteger)showsStateBy
The logical OR of flags that indicate the way the receiver shows its alternate state. See the “Constants” section of NSCell for the list of flags.
NSButtonCell.hReturns the sound that’s played when the user presses the receiver.
- (NSSound *)sound
The sound played when the receiver is pressed.
NSButtonCell.hReturns the title displayed on the receiver when it’s in its normal state.
- (NSString *)title
The title displayed by the button in its normal state, or the empty string if the button doesn’t display a title.
This title is always displayed if the button doesn’t use its alternate contents for highlighting or displaying the alternate state. By default, a button’s title is “Button.”
– setTitle:– alternateTitle– setButtonType:– mnemonic (NSCell)– mnemonicLocation (NSCell)NSButtonCell.hType to define bezel styles.
typedef NSUInteger NSBezelStyle;
For possible values, see “Bezel Styles.”
NSButtonCell.hDefine the bezel styles used by bezelStyle and setBezelStyle:.
enum {
NSRoundedBezelStyle = 1,
NSRegularSquareBezelStyle = 2,
NSThickSquareBezelStyle = 3,
NSThickerSquareBezelStyle = 4,
NSDisclosureBezelStyle = 5,
NSShadowlessSquareBezelStyle = 6,
NSCircularBezelStyle = 7,
NSTexturedSquareBezelStyle = 8,
NSHelpButtonBezelStyle = 9,
NSSmallSquareBezelStyle = 10,
NSTexturedRoundedBezelStyle = 11,
NSRoundRectBezelStyle = 12,
NSRecessedBezelStyle = 13,
NSRoundedDisclosureBezelStyle = 14,
}
NSRoundedBezelStyleA rounded rectangle button, designed for text.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSRegularSquareBezelStyleA rectangular button with a 2 point border, designed for icons.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSThickSquareBezelStyleA rectangular button with a 3 point border, designed for icons.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSThickerSquareBezelStyleA rectangular button with a 4 point border, designed for icons.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSDisclosureBezelStyleA bezel style for use with a disclosure triangle.
To create the disclosure triangle, set the button bezel style to NSDisclosureBezelStyle and the button type to NSOnOffButton.
Available in Mac OS X v10.3 and later.
Declared in NSButtonCell.h.
NSShadowlessSquareBezelStyleSimilar to NSRegularSquareBezelStyle, but has no shadow so you can abut the cells without overlapping shadows.
This style would be used in a tool palette, for example.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSCircularBezelStyleA round button with room for a small icon or a single character.
This style has both regular and small variants, but the large variant is available only in gray at this time.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSTexturedSquareBezelStyleA bezel style appropriate for use with textured (metal) windows.
Available in Mac OS X v10.3 and later.
Declared in NSButtonCell.h.
NSHelpButtonBezelStyleA round button with a question mark providing the standard help button look.
Available in Mac OS X v10.3 and later.
Declared in NSButtonCell.h.
NSSmallSquareBezelStyleA simple square bezel style. Buttons using this style can be scaled to any size.
Available in Mac OS X v10.4 and later.
Declared in NSButtonCell.h.
NSTexturedRoundedBezelStyleA textured (metal) bezel style similar in appearance to the Finder’s action (gear) button.
The height of this button is fixed.
Available in Mac OS X v10.4 and later.
Declared in NSButtonCell.h.
NSRoundRectBezelStyleA bezel style that matches the search buttons in Finder and Mail.
Available in Mac OS X v10.4 and later.
Declared in NSButtonCell.h.
NSRecessedBezelStyleA bezel style that matches the recessed buttons in Mail, Finder and Safari.
Available in Mac OS X v10.4 and later.
Declared in NSButtonCell.h.
NSRoundedDisclosureBezelStyleA bezel style that matches the disclosure style used in the standard Save panel.
Available in Mac OS X v10.4 and later.
Declared in NSButtonCell.h.
For examples of how these styles are displayed, see Button Programming Topics for Cocoa.
NSButtonCell.hType to define button types.
typedef NSUInteger NSButtonType;
For possible values, see “Button Types.”
NSButtonCell.hRepresent the button types that can be specified using setButtonType:.
enum {
NSMomentaryLightButton = 0,
NSPushOnPushOffButton = 1,
NSToggleButton = 2,
NSSwitchButton = 3,
NSRadioButton = 4,
NSMomentaryChangeButton = 5,
NSOnOffButton = 6,
NSMomentaryPushInButton = 7,
NSMomentaryPushButton = 0,
NSMomentaryLight = 7
};
NSMomentaryLightButtonWhile the button is held down it’s shown as “lit,” and also “pushed in” to the screen if the button is bordered.
This type of button is best for simply triggering actions, as it doesn’t show its state; it always displays its normal image or title. This option is called “Momentary Light” in Interface Builder’s Button Inspector.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSPushOnPushOffButtonThe first click both highlights and causes the button to be “pushed in” if the button is bordered; a second click returns it to its normal state.
This option is called “Push On Push Off” in Interface Builder’s Button Inspector.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSToggleButtonAfter the first click, the button displays its alternate image or title; a second click returns the button to its normal state.
This option is called “Toggle” in Interface Builder’s Button Inspector.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSSwitchButtonThis style is a variant of NSToggleButton that has no border and is used to represent a checkbox.
This type of button is available as a separate Library item in Interface Builder.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSRadioButtonThis style is similar to NSSwitchButton, but it used to constrain a selection to a single element from several.
You typically use this type of button in a group formed by an instance of NSMatrix. In Interface Builder, a matrix of this type of button is available as a separate Library item.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSMomentaryChangeButtonWhile the button is held down, the alternate image and alternate title are displayed.
The normal image and title are displayed when the button isn’t pressed. This option is called “Momentary Change” in Interface Builder’s Button Inspector.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSOnOffButtonThe first click highlights the button; a second click returns it to the normal (unhighlighted) state.
This option is called “On Off” in Interface Builder’s Button Inspector.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSMomentaryPushInButtonWhile the button is held down it’s shown as “lit.”
This type of button is best for simply triggering actions, as it doesn’t show its state; it always displays its normal image or title. This option is called “Momentary Push In” in Interface Builder’s Button Inspector.
This button type is the default.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSMomentaryPushButtonWhile the button is held down it’s shown as “lit,” and also “pushed in” to the screen if the button is bordered. (Deprecated. Use NSMomentaryLightButton instead.)
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSMomentaryLightWhile the button is held down it’s shown as “lit.” (Deprecated. Use NSMomentaryPushInButton instead.)
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
For examples of how these types behave, see Button Programming Topics for Cocoa.
NSButtonCell.hType to define gradient types.
typedef NSUInteger NSGradientType;
For possible values, see “Gradient Types.”
NSButtonCell.hSpecify the gradients used by gradientType and setGradientType:.
typedef enum _NSGradientType { NSGradientNone = 0, NSGradientConcaveWeak = 1, NSGradientConcaveStrong = 2, NSGradientConvexWeak = 3, NSGradientConvexStrong = 4 } NSGradientType;
NSGradientNoneThere is no gradient, so the button looks flat.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSGradientConcaveWeakThe top-left corner is light gray, and the bottom-right corner is dark gray, so the button appears to be pushed in.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSGradientConcaveStrongAs with NSGradientConcaveWeak, the top-left corner is light gray, and the bottom-right corner is dark gray, but the difference between the grays is greater, so the appearance of being pushed in is stronger.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSGradientConvexWeakThe top-left corner is dark gray, and the bottom-right corner is light gray, so the button appears to be sticking out.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSGradientConvexStrongAs with NSGradientConvexWeak, the top-left corner is dark gray, and the bottom-right corner is light gray, but the difference between the grays is greater, so the appearance of sticking out is stronger.
Available in Mac OS X v10.0 and later.
Declared in NSButtonCell.h.
NSButtonCell.h
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-04-08)