[SOLVED] How to receive text color changes from NSFontPanel?
[SOLVED] How to receive text color changes from NSFontPanel?
- Subject: [SOLVED] How to receive text color changes from NSFontPanel?
- From: Schwill Daniel <email@hidden>
- Date: Sat, 14 Oct 2006 16:03:08 +0200
Hi Martin,
Yes, changeAttribute: is sent to the first responder.
Maybe a little note in the NSFontPanel documentation would be nice. ;-)
Thanks!
Daniel
Am 13.10.2006 um 20:20 schrieb Martin:
The NSFontPanel has a control to change the text color, but how can I
receive a change of the text color from the NSFontPanel?
I believe the first responder is sent "changeAttributes:", which is
documented in the NSTextView reference. The general gist is that
you want to call "convertAttributes:" on the sender, eg:
- (void) changeAttributes:(id)sender
{
NSDictionary* oldAttrs = [self currentAttributes];
NSDictionary* newAttrs = [sender
convertAttributes:oldAttrs]; // adds color attribute
[self setCurrentAttributes:newAttrs];
}
If the NSColorPanel was brought up independently of the text view,
then I think you'll receive "changeColor:" instead of
"changeAttributes:".
I hope that helps,
~Martin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden