Re: Getting color attribute from NSFontPanel/NSFontManager
Re: Getting color attribute from NSFontPanel/NSFontManager
- Subject: Re: Getting color attribute from NSFontPanel/NSFontManager
- From: "Julio Cesar Silva dos Santos" <email@hidden>
- Date: Wed, 13 Dec 2006 08:02:12 -0200
Take a look at the [NSAttributedString initWithString: attributes:] method
and the NSAttributedString Application Kit Additions documentation to see
how to create an NSDictionary with all the attributes you want, specially
the constants NSForegroundColorAttributeName, NSUnderlineStyleAttributeName,
NSStrikethroughStyleAttributeName and NSStrikethroughColorAttributeName.
--
Julio Cesar Silva dos Santos
email@hidden
2006/12/13, Vinay Prabhu <email@hidden>:
Thanks foe the help, After setting the delegate, control is coming to
'changeFont'.
I have implemented changeFont, as given in the Font Panel documentation.
NSFont* newFont = [sender convertFont:oldFont];
The newFont object will have all the new attributes like Font Family, Font
Style,
Font Size etc, except for the Foreground Color, Text Underline and Text
StrikeThrough set in the Font Panel.
How to get the Text Underline, Text StrikeThrough and Text Color
attribute?
I need to apply these attributes to NSAttributedString and then display.
Is it possible ti create a NSAttributedAtring from NSFontManager which
will
have UnderLine, StrikeThrough etc?
Regards
Vinay
-----Original Message-----
From: cocoa-dev-bounces+vinayprabhu=email@hidden
[mailto:cocoa-dev-bounces+vinayprabhu=email@hidden]On
Behalf Of Julio Cesar Silva dos Santos
Sent: Tuesday, December 12, 2006 9:51 PM
To: Cocoa-Dev
Subject: Re: Getting color attribute from NSFontPanel/NSFontManager
You must set the delegate of the NSFontManager:
[[NSFontManager sharedFontManager] setDelegate:self];
Then changeFont: will be called.
--
Julio Cesar Silva dos Santos
email@hidden
2006/12/12, Vinay Prabhu <email@hidden>:
>
> Hi,
>
> I am trying to launch the Font Panel, when user clicks on the button in
> the
> window.
> The requirement is such that I can not use the Font Menu for launching
the
> Font Panel.
>
> The code,
>
> [[NSFontManager sharedFontManager] setAction:@selector(changeFont:)];
> [[NSFontManager sharedFontManager] orderFrontFontPanel:self];
>
> When new font is selected or any font attributes are changed (color
> attribute) in the Font Panel, "changeFont" action is not called.
>
> So to obtain the changes made in Font Panel, I have used following
> method.
> 1) I have registered the controller class to receive the
> NSWindowWillCloseNotification for NSFontPanel shared object.
> So that when Font Panel is closed, controller class will receive a
> notification.
> 2) In the windowWillClose method, I am trying to get the new font from
> Font
> Panel.
> NSFont* newFont = [[NSFontPanel sharedFontPanel]
> panelConvertFont:oldFont];
> The newFont object will have all the new attributes like Font Family,
Font
> Style, Font Size etc, except for the Foreground Color, Text Underline
and
> Text StrikeThrough set
> in the Font Panel.
>
> Is there anyway to obtain Foreground Color, Text Underline and Text
> StrikeThrough attributes from Font Panel?
>
> Regards
> Vinay
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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