Class

NSColorPanel

The NSColorPanel class provides a standard user interface for selecting color in an application. It provides a number of standard color selection modes and, with the NSColorPickingDefault and NSColorPickingCustom protocols, allows an application to add its own color selection modes. It allows the user to save swatches containing frequently used colors.

Symbols

Obtaining the Shared Color-Panel Object

class func shared()

Returns the shared NSColorPanel instance, creating it if necessary.

class func sharedColorPanelExists()

Returns a Boolean value indicating whether the NSColorPanel has been created already.

Configuring the Color Panel

var accessoryView: NSView?

The accessory view.

var isContinuous: Bool

A Boolean value indicating whether the receiver continuously sends the action message to the target.

var mode: NSColorPanelMode

The mode of the receiver the mode is one of the modes allowed by the color mask.

func setAction(Selector?)

Sets the color panel's action message.

func setTarget(Any?)

Sets the target of the receiver.

var showsAlpha: Bool

A Boolean value indicating whether or not the receiver shows alpha values and an opacity slider.

Managing Color Lists

func attachColorList(NSColorList)

Adds the list of NSColor objects specified to all the color pickers in the receiver that display color lists by invoking attachColorList(_:) on all color pickers in the application.

func detachColorList(NSColorList)

Removes the list of colors from all the color pickers in the receiver that display color lists by invoking detachColorList(_:) on all color pickers in the application.

Setting Color Picker Modes

class func setPickerMask(NSColorPanelOptions)

Determines which color selection modes are available in an application’s NSColorPanel.

class func setPickerMode(NSColorPanelMode)

Specifies the color panel’s initial picker.

Setting Color

class func dragColor(NSColor, with: NSEvent, from: NSView)

Drags a color into a destination view from the specified source view.

var color: NSColor

The color of the receiver.

Getting Color Information

var alpha: CGFloat

The receiver’s current alpha value based on its opacity slider.

Responding to a Color Change

func changeColor(Any?)

Sent to the first responder when the user selects a color in an NSColorPanel object.

Constants

Color Picker Mode Masks

Used to specify in the setPickerMask(_:) class method which of the color modes the NSColorPanel can use.

NSColorPanelMode

A type defined for the enum constants specifying color panel modes.

Color Panel Modes

Specify the active color mode used when an application’s instance of NSColorPanel is masked for more than one color mode.

Notifications

static let NSColorPanelColorDidChange: NSNotification.Name

Posted when the color of the NSColorPanel is set, as when NSColorPanel is invoked.

Relationships

Inherits From