Mac Developer Library

Developer

AppKit Framework Reference NSColorPickingCustom Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSColorPickingCustom

Inheritance


Not Applicable

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

Together with the NSColorPickingDefault protocol, NSColorPickingCustom provides a way to add 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 NSColorPicker class adopts the NSColorPickingDefault protocol.

  • Adjusts the receiver to make the specified color the currently selected color. (required)

    Declaration

    Swift

    func setColor(_ color: NSColor)

    Objective-C

    - (void)setColor:(NSColor *)color

    Parameters

    color

    The color to set as the currently selected color.

    Discussion

    This method is invoked on the current color picker each time NSColorPanel’s setColor: method is invoked. If color is actually different from the color picker’s color (as it would be if, for example, the user dragged a color into NSColorPanel’s color well), this method could be used to update the color picker’s color to reflect the change.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s current mode (or submode, if applicable). (required)

    Declaration

    Swift

    func currentMode() -> NSColorPanelMode

    Objective-C

    - (NSColorPanelMode)currentMode

    Return Value

    The current color picker mode. The returned value should be unique to your color picker. See this protocol description’s list of the unique values for the standard color pickers used by the Application Kit.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a Boolean value indicating whether or not the receiver supports the specified picking mode. (required)

    Declaration

    Swift

    func supportsMode(_ mode: NSColorPanelMode) -> Bool

    Objective-C

    - (BOOL)supportsMode:(NSColorPanelMode)mode

    Parameters

    mode

    The color picking mode.

    Return Value

    YEStrue if the color picker supports the specified color picking mode; otherwise NOfalse.

    Discussion

    This method is invoked when the NSColorPanel is first initialized: It is used to attempt to restore the user’s previously selected mode. It is also invoked by NSColorPanel's setMode: method to find the color picker that supports a particular mode. See this protocol description’s list of the unique mode values for the standard color pickers used by the Application Kit.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – currentMode

  • Returns the view containing the receiver’s user interface. (required)

    Declaration

    Swift

    func provideNewView(_ initialRequest: Bool) -> NSView

    Objective-C

    - (NSView *)provideNewView:(BOOL)initialRequest

    Parameters

    initialRequest

    YEStrue only when this method is first invoked for your color picker. If initialRequest is YEStrue, the method should perform any initialization required (such as lazily loading a nib file, initializing the view, or performing any other custom initialization required for your picker).

    Return Value

    The view containing the color picker's user interface. The NSView returned by this method should be set to automatically resize both its width and height.

    Discussion

    This message is sent to the color picker whenever the color panel attempts to display it. This may be when the panel is first presented, when the user switches pickers, or when the picker is switched through an API.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.