NSColorPicker 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
NSColorPicker.h
Related sample code

Overview

The NSColorPicker class is an abstract superclass that implements the NSColorPickingDefault protocol. The NSColorPickingDefault and NSColorPickingCustom protocols define a way to add color pickers (custom user interfaces for color selection) to the NSColorPanel.

Adopted Protocols

NSColorPickingDefault

Tasks

Initializing an NSColorPicker Object

Getting the Color Panel

Adding Button Images

Setting the Mode

Mananging Color Lists

Responding to View Changes

Customizing the Color Picker

Instance Methods

attachColorList:

Does nothing. Override to attach a color list to a color picker.

- (void)attachColorList:(NSColorList *)colorList
Parameters
colorList

The color list to attach to the color picker.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSColorPicker.h

buttonToolTip

Returns the tool tip to be shown when the mouse cursor is over the receiver’s button image.

- (NSString *)buttonToolTip
Return Value

A string representing the tool tip.

Discussion

Override this method to provide a custom tool tip. The default implementation of this method returns the name of the receiver’s class. If you want the color picker to have no tool tip, return an empty string.

Availability
  • Available in OS X v10.5 and later.
Related Sample Code
Declared In
NSColorPicker.h

colorPanel

Returns the NSColorPanel that owns the receiver.

- (NSColorPanel *)colorPanel
Return Value

The owning color panel.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSColorPicker.h

detachColorList:

Does nothing. Override to detach a color list from a color picker.

- (void)detachColorList:(NSColorList *)colorList
Parameters
colorList

The color list to detach.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSColorPicker.h

initWithPickerMask:colorPanel:

Initializes the color picker with the specified color panel and color picker mode mask.

- (id)initWithPickerMask:(NSUInteger)mask colorPanel:(NSColorPanel *)owningColorPanel
Parameters
mask

The color picker mask.

owningColorPanel

The NSColorPanel that owns the color picker. This value is cached so it can be returned later by the colorPanel method.

Return Value

An initialized color picker object.

Discussion

Override this method to respond to the values in mask or do other custom initialization. If you override this method in a subclass, you should forward the message to super as part of the implementation.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSColorPicker.h

insertNewButtonImage:in:

Sets the image used for the specified button cell.

- (void)insertNewButtonImage:(NSImage *)newButtonImage in:(NSButtonCell *)buttonCell
Parameters
newButtonImage

The image used for the specified button cell.

buttonCell

The button cell for which to set the image.

Discussion

Called by the color panel to insert a new image into the specified cell by invoking NSButtonCell’s setImage: method. Override this method to customize newButtonImage before insertion in buttonCell.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSColorPicker.h

minContentSize

Returns the minimum content size for the receiver.

- (NSSize)minContentSize
Return Value

The minimum size of the receiver, an NSColorPicker object. The NSColorPanel object does not allow the color picker to be made smaller than this size.

Discussion

Override this method to return a minimum size for the color picker’s content area. The default implementation of this method obtains the minimum content size from the view-autoresizing behavior specified for the receiver and returns that. You should not have to override this method if you properly set up the color picker’s auto-sizing attributes in Interface Builder.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSColorPicker.h

provideNewButtonImage

Returns the button image for the receiver.

- (NSImage *)provideNewButtonImage
Return Value

The image placed on the mode button the user uses to select this color picker. This is the same image the color panel uses as an argument when sending the insertNewButtonImage:in: message.) The default implementation looks in the color picker’s bundle for a TIFF file named after the color picker’s class, with the extension “.tiff”.

Availability
  • Available in OS X v10.0 and later.
Related Sample Code
Declared In
NSColorPicker.h

setMode:

Does nothing. Override to set the color picker’s mode.

- (void)setMode:(NSColorPanelMode)mode
Parameters
mode

A constant specifying the color picking mode. These constants are defined in AppKit/NSColorPanel.h.

Discussion

In grayscale-alpha, red-green-blue, cyan-magenta-yellow-black, and hue-saturation-brightness modes, the user adjusts colors by manipulating sliders. In the custom palette mode, the user can load an NSImage file (TIFF or EPS) into the NSColorPanel, then select colors from the image. In custom color list mode, the user can create and load lists of named colors. The two custom modes provide NSPopUpLists for loading and saving files. Finally, color wheel mode provides a simplified control for selecting colors.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSColorPicker.h

viewSizeChanged:

Does nothing. Override to respond to a size change.

- (void)viewSizeChanged:(id)sender
Availability
  • Available in OS X v10.0 and later.
Declared In
NSColorPicker.h