I have a preferences panel in my application in which I have a NSColorWell
for setting some background color and a button which opens an NSFontPanel
for choosing a font.
The behavior I want to have is the following:
When I click on the NSColorWell
then drag over some color in the panel, I want it to change the background color in my "preview" area as I drag.
When I click on the "Change font..." button, I show my NSFontPanel
and as I choose a font it should change in my "preview" area too. Say I click on the color button of the NSFontPanel
, I want to change the color of my font.
In essence I'm trying to make both color panels (although from what I've seen there's really only one shared panel per app) work independently.
Right now, say I have the font and color panels opened. When I click on the color well on my window it activates, then if I click on the color button in the font panel the color does not affect the font but rather the background, as the color well stays activated and because I registered for color change notifications in my controller class.
Could someone give me an example of a specific way to code this kind of behavior? There seems to be a bunch of different ways to make the NSFontPanel
and NSColorPanel
show up (NSFontPanel
or NSFontManager
?), as well as many ways to handle the events coming from the panels themselves (notifications? delegates (on the NSFontManager
or NSFontPanel
)? inserting the controller into the responder chain?). I haven't found any guidelines on a ideal way to handle more than one color sources at once and I'm a little lost.
Thanks in advance!
The color picker mechanism is specifically designed so that you can "activate" multiple color wells, then set their color simultaneously. I believe the reason why the font panel's color button doesn't "let go" of the color picker is because it's apparently not actually a "color well". I haven't noticed this behavior directly but it's easily reproducible with a simple fresh xib with a color well and a standard text view.
Essentially, you can click both the well and the font color and both the well and selected text will change to the picked color. You can even turn off the well and only the text will change. You can't, however, make the font panel "let go" of the color picker until you close the font panel.
I'd call this a bug: http://bugreport.apple.com