Mac Developer Library

Developer

AppKit Framework Reference NSColorPicker Class Reference

Options
Deployment Target:

On This Page
Language:

NSColorPicker

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

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.

  • 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 accessed using the colorPanel property.

    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

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    colorPanel

  • The NSColorPanel instance that owns the color picker. (read-only)

    Declaration

    Swift

    var colorPanel: NSColorPanel { get }

    Objective-C

    @property(readonly, strong) NSColorPanel *colorPanel

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    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

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The button image used by the color picker. (read-only)

    Declaration

    Swift

    var provideNewButtonImage: NSImage { get }

    Objective-C

    @property(readonly, strong) NSImage *provideNewButtonImage

    Discussion

    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. Override this property’s getter method to provide a custom button image. 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

    Objective-C

    @import AppKit;

    Swift

    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

    Objective-C

    @import AppKit;

    Swift

    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

    Objective-C

    @import AppKit;

    Swift

    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

    Objective-C

    @import AppKit;

    Swift

    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

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The tool tip that is shown when the mouse cursor is over the color picker’s button image. (read-only)

    Declaration

    Swift

    var buttonToolTip: String { get }

    Objective-C

    @property(readonly, copy) NSString *buttonToolTip

    Discussion

    Override this property’s getter method to provide a custom tool tip. The default implementation 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

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • the minimum content size. (read-only)

    Declaration

    Swift

    var minContentSize: NSSize { get }

    Objective-C

    @property(readonly) NSSize minContentSize

    Discussion

    The containing NSColorPanel object does not allow the color picker to be made smaller than this size.

    Override this property’s getter method to return a minimum size for the color picker’s content area. The default implementation obtains the minimum content size from the view-autoresizing behavior specified for the color picker. 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

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.