• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I change the font of selected text in an NSTextView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I change the font of selected text in an NSTextView?


  • Subject: Re: How do I change the font of selected text in an NSTextView?
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 09 Mar 2005 18:06:55 -0800

On 2005-03-09 17:00:14 -0800 Dave Camp <email@hidden> wrote:

My application has a popup menu with a list of fonts and an NSTextView with text typed by the user. If the user selects some text and chooses a font from the menu, I want to change the selected text to that font. Seem like that should be easy enough to do, but I can't find anything close. I've been through the NSTextVew, NSText, and NSFontManager APIs but this eludes me.

I was hoping there would be something similar to [[NSFontManager sharedFontManager] addFontTrait:sender] which I use for my Bold and Italics buttons.

You can send changeAttributes: with an appropriate object as sender. NSTextView implements this, and will call back to the sender with a convertAttributes: message for each set of attributes in the selected text. You then perform any transformation you wish, and return the transformed attributes, leaving unchanged any attributes you do not wish to touch. In this case presumably you would simply change the font attribute, if necessary using NSFontManager to convert the existing font.


Douglas Davidson

_______________________________________________
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


References: 
 >How do I change the font of selected text in an NSTextView? (From: Dave Camp <email@hidden>)

  • Prev by Date: NSPopUpButton is leaking?
  • Next by Date: Re: Question to Apple: When do GetThemeImage() or GetThemePattern get called
  • Previous by thread: How do I change the font of selected text in an NSTextView?
  • Next by thread: NSBezierPath and NSAffineTransform
  • Index(es):
    • Date
    • Thread