Close NSColorPanel



I was wondering how you closed the NSColorPanel programatically upon closing the Preferences window?

I’ve tried to subclass the NSColorWell and fire up the NSCOlorPanel with [[NSColorPanel sharedColorPanel] makeKeyAndOrderFront:self]; which seems to work well. But upon picking, it makes no difference.

I did try to use [[NSColorPanel sharedColorPanel] setTarger:self] (in the NSColorWell subclass, but that makes no difference.

Any pointers?




Just to add that I’ve resolved this.

After doing some research in the NSColorPanel class, it appears that usually there is only one ‘shared’ ColorPanel per Application (note usually, dependson the app). I managed to resolve the issue by doing this:

    NSColor *color = [colorWell color];
    NSLog(@"Color changed: %@", color );
    [[NSColorPanel sharedColorPanel] orderOut:nil];
    [colorWell deactivate];