Mac Developer Library

Developer

AppKit Framework Reference NSColorPicker Class Reference

Options
Deployment Target:

On This Page
Language:

NSColorPicker

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.

Inheritance


Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.0 and later.
  • Initializes the color picker with the specified color panel and color picker mode mask.

    Declaration

    Swift

    init?(pickerMask mask: Int, colorPanel owningColorPanel: NSColorPanel)

    Objective-C

    - (instancetype)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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – colorPanel

  • Returns the NSColorPanel that owns the receiver.

    Declaration

    Swift

    var colorPanel: NSColorPanel { get }

    Objective-C

    @property(readonly, strong) NSColorPanel *colorPanel

    Return Value

    The owning color panel.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the image used for the specified button cell.

    Declaration

    Swift

    func insertNewButtonImage(_ newButtonImage: NSImage, `in` buttonCell: NSButtonCell)

    Objective-C

    - (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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the button image for the receiver.

    Declaration

    Swift

    var provideNewButtonImage: NSImage { get }

    Objective-C

    @property(readonly, strong) 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”.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func setMode(_ mode: NSColorPanelMode)

    Objective-C

    - (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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func attachColorList(_ colorList: NSColorList)

    Objective-C

    - (void)attachColorList:(NSColorList *)colorList

    Parameters

    colorList

    The color list to attach to the color picker.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func detachColorList(_ colorList: NSColorList)

    Objective-C

    - (void)detachColorList:(NSColorList *)colorList

    Parameters

    colorList

    The color list to detach.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Does nothing. Override to respond to a size change.

    Declaration

    Swift

    func viewSizeChanged(_ sender: AnyObject?)

    Objective-C

    - (void)viewSizeChanged:(id)sender

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var buttonToolTip: String { get }

    Objective-C

    @property(readonly, copy) 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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the minimum content size for the receiver.

    Declaration

    Swift

    var minContentSize: NSSize { get }

    Objective-C

    @property(readonly) 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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.