xcodemacosnscolorwell

How can I dismiss the color picker that appears with an NSColorWell


A HUD popup window in my app includes an NSColorWell so that the user can chose a color for data on a graph.

Once the user clicks the NSColorWell, the Color Picker appears - thats good so far. Once they have finished with the HUD window and they click outside it, it automatically disappears, but the Color Picker remains on-screen unless they specifically hit it's red close button.

Is there a way to programmatically dismiss or hide the color picker when we are done with it?


Solution

  • Using Swift language, you can do this to close the NSColorWell:

    NSColorPanel.sharedColorPanel().orderOut(nil)
    colorWellReach.deactivate()