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

1.9k views Asked by At

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?

3

There are 3 answers

2
Aarhus88 On BEST ANSWER

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

NSColorPanel.sharedColorPanel().orderOut(nil)
colorWellReach.deactivate()
0
Bob Ueland On

Call [[NSColorPanel sharedColorPanel] close]; where you want the Color Picker to disappear

0
vomi On

Swift 5

NSColorPanel.shared.close()