RE: Getting color attribute from NSFontPanel/NSFontManager
RE: Getting color attribute from NSFontPanel/NSFontManager
- Subject: RE: Getting color attribute from NSFontPanel/NSFontManager
- From: Vinay Prabhu <email@hidden>
- Date: Mon, 18 Dec 2006 11:58:13 +0530
- Importance: Normal
I could create a NSAttributedString object with all attributes I wanted.
My problem is, how do I retrive the changes made in the NSFontPanel. i.e,
Foreground Color, Underline, StrikeThrough.
What I understand from the documentation is, If I am using text field, I
need to drag and drop Font menu to the menu in IB.
Then call setUsesFontPanel:YES for the text field object.
When I do this, any change I made in Font Panel, immediately applies the
changes to text in text field.
The same way, How do I get the ForeGround Color, UnderLine and StrikeThrough
attributes from Font Panel,
In order to apply these attributes to NSAttributedString?
-----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: Wednesday, December 13, 2006 3:32 PM
To: Cocoa-Dev
Subject: Re: Getting color attribute from NSFontPanel/NSFontManager
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:
in
This email sent to email@hidden
_______________________________________________
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