How to only get color change messages when the user changes color?
How to only get color change messages when the user changes color?
- Subject: How to only get color change messages when the user changes color?
- From: Gideon King <email@hidden>
- Date: Wed, 24 Mar 2010 20:02:28 +1000
Hi All
I have an NSTextView subclass, and when I make it first responder, it updates the color in the color panel, which causes the color panel to send a changeColor: message. Ditto when I change the selection.
In some cases, the color of my text is affected by things other than my textview, but when the user explicitly sets the color, I want to honor their wishes and turn off the automatic coloring. So when I get told that the color has changed, when in fact it's just synchronizing the color value with the text color, this causes a problem. I want to only receive color changed messages when the user actually changes the color. I can't just compare the old text color with the new color to know whether it has been changed by the user because the old color may have been automatically set.
I imagine I can override changeColor: in my subclass and do nothing when this message is received, and send the shared color panel a setTarget: and setAction: whenever my text field becomes first responder, and then reset them back to nil when it resigns first responder, but I would think that this would get past the initial issue when the text field becomes first responder, but I would still be receiving them whenever the selection changed - is this correct? Also I see that a NSColorPanelColorDidChangeNotification notification is sent, but again, it appears that it would be sent when the system is just synchronizing the color panel with the color of the text.
If none of these ways will help, how am I supposed to know when the user actually changes the color?
Thanks
Gideon
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden