---
title: NSButtonCell
framework: appkit
role: symbol
role_heading: Class
path: appkit/nsbuttoncell
---

# NSButtonCell

An object that defines the user interface of a button or other clickable region of a view.

## Declaration

```swift
class NSButtonCell
```

## Overview

Overview Setting the integer, float, double, or object value of an NSButtonCell object results in a call to state with the value converted to integer. In the case of objectValue, 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, for most button types, 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 true for on, false for off, and integer value -1 for the mixed state. For accelerator buttons (type NSAcceleratorButton or NSMultiLevelAcceleratorButton) on systems that support pressure sensitivity, querying doubleValue returns the amount of pressure applied while pressing the button. The configuration of an NSButtonCell object controls how the button object appears and behaves, but it’s NSButton that sends a message when the control is clicked. For more information on the behavior of NSButtonCell, see the NSButton and NSMatrix class specifications. Exceptions In its implementation of the compare(_:) method (declared in NSCell), NSButtonCell raises an NSBadComparisonException if the otherCell argument is not of the NSButtonCell class. Fonts Setting the font property does nothing if the button 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.

## Topics

### Creating the Cell

- [init(coder:)](appkit/nsbuttoncell/init(coder:).md)
- [init(imageCell:)](appkit/nsbuttoncell/init(imagecell:).md)
- [init(textCell:)](appkit/nsbuttoncell/init(textcell:).md)

### Setting Titles

- [alternateTitle](appkit/nsbuttoncell/alternatetitle.md)
- [attributedAlternateTitle](appkit/nsbuttoncell/attributedalternatetitle.md)
- [attributedTitle](appkit/nsbuttoncell/attributedtitle.md)
- [title](appkit/nsbuttoncell/title.md)

### Managing Images

- [alternateImage](appkit/nsbuttoncell/alternateimage.md)
- [imagePosition](appkit/nsbuttoncell/imageposition.md)
- [imageScaling](appkit/nsbuttoncell/imagescaling.md)

### Managing the Repeat Interval

- [getPeriodicDelay(_:interval:)](appkit/nsbuttoncell/getperiodicdelay(_:interval:).md)
- [setPeriodicDelay(_:interval:)](appkit/nsbuttoncell/setperiodicdelay(_:interval:).md)

### Managing the Key Equivalent

- [keyEquivalent](appkit/nsbuttoncell/keyequivalent.md)
- [keyEquivalentFont](appkit/nsbuttoncell/keyequivalentfont.md)
- [keyEquivalentModifierMask](appkit/nsbuttoncell/keyequivalentmodifiermask.md)
- [setKeyEquivalentFont(_:size:)](appkit/nsbuttoncell/setkeyequivalentfont(_:size:).md)

### Managing Graphics Attributes

- [backgroundColor](appkit/nsbuttoncell/backgroundcolor.md)
- [bezelStyle](appkit/nsbuttoncell/bezelstyle.md)
- [gradientType](appkit/nsbuttoncell/gradienttype.md)
- [imageDimsWhenDisabled](appkit/nsbuttoncell/imagedimswhendisabled.md)
- [isOpaque](appkit/nsbuttoncell/isopaque.md)
- [isTransparent](appkit/nsbuttoncell/istransparent.md)
- [showsBorderOnlyWhileMouseInside](appkit/nsbuttoncell/showsborderonlywhilemouseinside.md)

### Displaying the Cell

- [highlightsBy](appkit/nsbuttoncell/highlightsby.md)
- [setButtonType(_:)](appkit/nsbuttoncell/setbuttontype(_:).md)
- [showsStateBy](appkit/nsbuttoncell/showsstateby.md)

### Managing the Sound

- [sound](appkit/nsbuttoncell/sound.md)

### Handling Events and Action Messages

- [mouseEntered(with:)](appkit/nsbuttoncell/mouseentered(with:).md)
- [mouseExited(with:)](appkit/nsbuttoncell/mouseexited(with:).md)
- [performClick(_:)](appkit/nsbuttoncell/performclick(_:).md)

### Drawing the Button Content

- [drawBezel(withFrame:in:)](appkit/nsbuttoncell/drawbezel(withframe:in:).md)
- [drawImage(_:withFrame:in:)](appkit/nsbuttoncell/drawimage(_:withframe:in:).md)
- [drawTitle(_:withFrame:in:)](appkit/nsbuttoncell/drawtitle(_:withframe:in:).md)

### Constants

- [NSButton.BezelStyle](appkit/nsbutton/bezelstyle-swift.enum.md)
- [NSButton.ButtonType](appkit/nsbutton/buttontype.md)
- [NSButton.GradientType](appkit/nsbutton/gradienttype.md)

## Relationships

### Inherits From

- [NSActionCell](appkit/nsactioncell.md)

### Inherited By

- [NSMenuItemCell](appkit/nsmenuitemcell.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSAccessibilityElementProtocol](appkit/nsaccessibilityelementprotocol.md)
- [NSAccessibilityProtocol](appkit/nsaccessibilityprotocol.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSUserInterfaceItemIdentification](appkit/nsuserinterfaceitemidentification.md)
