How can I dismiss the color picker?

OS X Cocoa App.

I have a Popover window that allows the user to choose a colour for a line on a graph.

It uses an NSColorWell. When the user clicks in the well, the Colour Picker appears - which is good.


When the user is done, they click away from the Popover and it disappears, but unless they specifically dismiss the colour picker it remains on screen.

How can I programatically dismiss the colour picker?


See the following screen shots for the sequence of events I am referring to. In Screen Shot 4 I would like the colour picker to disappear.


Screen Shot 1

Screen Shot 2

Screen Shot 3

Screen Shot 4


Thanks!

Since NSColorPanel is an NSPanel subclass, you can call `-close` or `-orderOut:` on the panel to dismiss it.


Though, as a side note, the typical user interaction for NSColorPanel is for it to stay around until the user closes it. Check out TextEdit, or the iWork apps. After the user clicks a color well to show the color panel, it's never programmatically dismissed.

Thanks for the reply.

In my instance it definitely make sense to dismiss the colour picker beasue it belongs to a control, in an HUD Popop window which has since been dismissed.


However, I don't see how I can send it -close or -orderOut when I don't have a handle on the window, in other words, how do I access it, to order it out / closed?

Can I just search my Application's subviews until I find one of class NSColourPanel?

It's possible it's using the sharedColorPanel in which case you could just do


    if ([[NSColorPanel sharedColorPanel] isVisible]) {
        [[NSColorPanel sharedColorPanel] orderOut:nil];
    }
How can I dismiss the color picker?
 
 
Q