• 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: Need help setting font of NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help setting font of NSTextView


  • Subject: Re: Need help setting font of NSTextView
  • From: Doug Brown <email@hidden>
  • Date: Thu, 10 Jan 2002 16:14:28 -0800

Hi Douglas,

I tried overriding rangeForUserCharacterAttributeChange to:
return NSMakeRange(0, [[self string] length]);

And it only seems to change the font attributes when there is nothing inside the textView. Any ideas?

Thanks,

Doug

On Thursday, January 10, 2002, at 10:27 AM, Douglas Davidson wrote:


On Wednesday, January 9, 2002, at 10:19 PM, Doug Brown wrote:

I'm having trouble figuring out how to what seems like a simple task in Cocoa. I have an NSTextView that is not editable, and I want to be able to use NSFontPanel (or just a menu with the font names in it or something) to set the font (and size) of the entire text within it. I've been trying to read the documentation, but it's confusing me. Does NSFontPanel only work when you're using an editable text view? If possible, I'd also like to simultaneously set the font of an NSTextField when that happens. Could anyone guide me in the right direction? Thanks!

When a textview isn't editable, the user can't change it. The method that is called when changes occur in the font panel is changeFont:, and this and a number of other methods apply their changes to the range returned from rangeForUserCharacterAttributeChange. If a textview is not editable, rangeForUserCharacterAttributeChange returns {NSNotFound, 0}, which prevents these sorts of changes from taking effect. If the textview is editable, then changeFont: calls the font manager method convertFont: on each font present in the text, to apply the changes made in the font panel to the text.

You should be able to do what you want by subclassing and overriding changeFont:, rangeForUserCharacterAttributeChange, or both.

Douglas Davidson


  • Follow-Ups:
    • Re: Need help setting font of NSTextView
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: Need help setting font of NSTextView (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Distributed Objects problem
  • Next by Date: Re: Easiest way to delete a file
  • Previous by thread: Re: Need help setting font of NSTextView
  • Next by thread: Re: Need help setting font of NSTextView
  • Index(es):
    • Date
    • Thread