Mac Developer Library

Developer

AppKit Framework Reference NSColorPickingDefault Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSColorPickingDefault

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

The NSColorPickingDefault protocol, together with the NSColorPickingCustom protocol, provides an interface for adding color pickers—custom user interfaces for color selection—to an application’s NSColorPanel instance. The NSColorPickingDefault protocol provides basic behavior for a color picker. The NSColorPickingCustom protocol provides implementation-specific behavior.

  • Initializes the receiver with a given color panel and its mode.

    Declaration

    Swift

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

    Objective-C

    - (instancetype)initWithPickerMask:(NSUInteger)panelModes colorPanel:(NSColorPanel *)owningColorPanel

    Parameters

    panelModes

    A mask indicating the various color picker modes supported by the color panel. This is determined by the argument to the NSColorPanel method setPickerMask:. If it has not been set, panelModes is NSColorPanelAllModesMask. If your color picker supports any additional modes, you should invoke the setPickerMask: method when your application initializes to notify the NSColorPanel class. The standard mode constants are defined in Choosing the Color Pickers in a Color Panel.

    owningColorPanel

    The color panel than owns the receiver.

    Return Value

    If your color picker responds to any of the modes represented in panelModes, it should perform its initialization and return an initialized color picker. Color pickers that do so have their buttons inserted in the color panel and continue to receive messages from the panel as the user manipulates it. If the color picker doesn’t respond to any of the modes represented in panelModes, it should do nothing and return nil.

    Discussion

    This method is sent by the NSColorPanel to all implementors of the color-picking protocols when the application’s color panel is first initialized. In order for your color picker to receive this message, it must have a bundle in your application’s “ColorPickers” directory (described in Color Picker Bundles).

    This method should examine the mask and determine whether it supports any of the modes included there. You may also check the value in mask to enable or disable any subpickers or optional controls implemented by your color picker. Your color picker may also retain owningColorPanel in an instance variable for future communication with the color panel.

    This method is provided to initialize your color picker; however, much of a color picker’s initialization may be done lazily through the NSColorPickingCustom protocol’s provideNewView: method.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    + setPickerMask: (NSColorPanel class)

  • Specifies the receiver’s mode.

    Declaration

    Swift

    func setMode(_ mode: NSColorPanelMode)

    Objective-C

    - (void)setMode:(NSColorPanelMode)mode

    Parameters

    mode

    The color picker mode. The available modes are described in Choosing the Color Pickers in a Color Panel.

    Discussion

    This method is invoked by the NSColorPanel method setMode: method to ensure the color picker reflects the current mode. For example, invoke this method during color picker initialization to ensure that all color pickers are restored to the mode the user left them in the last time an NSColorPanel was used.

    Most color pickers have only one mode and thus don’t need to do any work in this method. An example of a color picker that uses this method is the slider picker, which can choose from one of several submodes depending on the value of mode.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the image of a given button cell.

    Declaration

    Swift

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

    Objective-C

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

    Parameters

    newButtonImage

    The image to set for the button cell.

    buttonCell

    The NSButtonCell object that lets the user choose the picker from the color panel—the color picker’s representation in the NSMatrix of the NSColorPanel.

    Discussion

    This method should perform application-specific manipulation of the image before it’s inserted and displayed by the button cell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Provides the image of the button used to select the receiver in the color panel.

    Declaration

    Swift

    func provideNewButtonImage() -> NSImage

    Objective-C

    - (NSImage *)provideNewButtonImage

    Return Value

    The image for the mode button the user uses to select this picker in the color panel; that is, the color picker's representation in the NSMatrix of the NSColorPanel.

    This image is the same one the color panel uses as an argument when sending the insertNewButtonImage:in: message.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Indicates the receiver’s minimum content size.

    Declaration

    Swift

    func minContentSize() -> NSSize

    Objective-C

    - (NSSize)minContentSize

    Discussion

    The receiver does not allow a size smaller than minContentSize.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Provides the toolbar button help tag.

    Declaration

    Swift

    func buttonToolTip() -> String

    Objective-C

    - (NSString *)buttonToolTip

    Return Value

    Help tag text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Sent when the color panel's opacity controls have been hidden or displayed.

    Declaration

    Swift

    func alphaControlAddedOrRemoved(_ sender: AnyObject?)

    Objective-C

    - (void)alphaControlAddedOrRemoved:(id)sender

    Parameters

    sender

    The color panel sending the message.

    Discussion

    This method is invoked automatically when the opacity slider of the NSColorPanel is added or removed; you never invoke this method directly.

    If the color picker has its own opacity controls, it should hide or display them, depending on whether the sender’s showsAlpha method returns NOfalse or YEStrue.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Tells the recever when the color panel's view size changes in a way that might affect the color picker.

    Declaration

    Swift

    func viewSizeChanged(_ sender: AnyObject?)

    Objective-C

    - (void)viewSizeChanged:(id)sender

    Parameters

    sender

    The NSColorPanel that contains the color picker.

    Discussion

    Use this method to perform special preparation when resizing the color picker’s view. Because this method is invoked only as appropriate, it’s better to implement this method than to override the method superviewSizeChanged: for the NSView in which the color picker’s user interface is contained.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – provideNewView: (NSColorPickingCustom protocol)

  • Tells the receiver to attach the given color list, if it isn’t already displaying the list.

    Declaration

    Swift

    func attachColorList(_ colorList: NSColorList)

    Objective-C

    - (void)attachColorList:(NSColorList *)colorList

    Parameters

    colorList

    The color list to display.

    Discussion

    You never invoke this method; it’s invoked automatically by the NSColorPanel object when its attachColorList: method is invoked. Because the NSColorPanel list mode manages NSColorList objects, this method need only be implemented by a custom color picker that manages NSColorList objects itself.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Tells the receiver to detach the given color list, unless the receiver isn’t displaying the list.

    Declaration

    Swift

    func detachColorList(_ colorList: NSColorList)

    Objective-C

    - (void)detachColorList:(NSColorList *)colorList

    Parameters

    colorList

    The color list to detach.

    Discussion

    You never invoke this method; it’s invoked automatically by the NSColorPanel object when its detachColorList: method is invoked. Because the NSColorPanel list mode manages NSColorList objects, this method need only be implemented by a custom color picker that manages NSColorList objects itself.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.