Re: Getting NSFontPanel color changes [SOLVED]
Re: Getting NSFontPanel color changes [SOLVED]
- Subject: Re: Getting NSFontPanel color changes [SOLVED]
- From: Glen Low <email@hidden>
- Date: Tue, 27 Apr 2004 06:57:20 +0800
Douglas:
On 27/04/2004, at 4:38 AM, Douglas Davidson wrote:
On Apr 26, 2004, at 1:53 AM, Glen Low wrote:
Apparently the NSFontPanel sends an undocumented
setColor:forAttribute: message to the responder chain, where the
first param is an NSColor and the second is a NSString which has the
attribute name to change (either color or background color).
Interestingly enough, none of the AppKit actually seem to declare
this message (by doing an otool -ov AppKit | grep "setColor" | get
"forAttribute") ... I only found it by overriding
"respondsToSelector" to see what methods the NSFontPanel was probing
for.
Note that our intent in future is for color changes to go through
public mechanisms, namely changeColor: for the foreground color,
changeDocumentBackgroundColor: for the document background color, and
changeAttributes: for other colors. The latter two methods are new in
Panther and are documented in the Panther release notes. We simply
didn't get the font panel changes hooked up to them for Panther.
Thanks for the official word. My main frustration was that obviously
NSTextView and friends were allowing foreground color and background
color to be changed via changeColor: and
changeDocumentBackgroundColor:, but my own NSResponder classes were not
receiving these messages.
What would be a practical solution that would work in Panther and
future releases?
1. Handle setColor:forAttribute: and dispatch to changeColor: and
changeDocumentBackgroundColor: appropriately? So in 10.4 the code would
still work since changeColor: and changeDocumentBackgroundColor: would
be called directly.
2. Forget about changing foreground and background colors through the
font panel. Is there any flag or mode I can use to turn the style
selections off?
3. Overriding NSText or NSTextView directly. (Somewhat of a kludge
because I don't need the entire functionality of NSText/NSTextView --
I'm working on something equivalent to a Preferences setting.)
4. Some other supported mechanism?
I'm not sure why, from a design point of view, the color isn't just
reflected in the changeAttributes: message.
Cheers, Glen Low
---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.