• 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: workaround: stubborn text attributes in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: workaround: stubborn text attributes in NSTextView


  • Subject: Re: workaround: stubborn text attributes in NSTextView
  • From: Andy Lee <email@hidden>
  • Date: Wed, 27 May 2009 19:01:43 -0400

On Wednesday, May 27, 2009, at 06:34PM, "Kyle Sluder" <email@hidden> wrote:
>On Wed, May 27, 2009 at 2:58 PM, Andy Lee <email@hidden> wrote:
>> I configured an NSTextView in IB with a custom text color, a bit of dummy text with a custom font, and rich text turned off (i.e., it's plain text).  The problem was that when the user deletes all the text, the text view reverts to black Helvetica 12.
>
>Just did this yesterday.  Sign yourself up as the text storage's
>delegate (or listen for its
>NSTextStorageWillProcessEditingNotification) and implement
>-textStorageWillProcessEditing: to force your desired attributes.

Thanks, Kyle -- the problem is, I would have to construct a typingAttributes dictionary in code.  I can't grab it from the text view because the text view returns nil.  I prefer my workaround because it's simpler and it uses settings I've already selected in IB and shouldn't have to reproduce in code.  (Although on the other hand, the behavior I observed isn't documented, so my workaround could conceivably break in a future release.)

Bear in mind that in my case the text view is plain text, so I don't have the problem of preserving typing attributes that the user created.  Rather, I'm trying to get the text view to stick with the typing attributes that *I* created.

--Andy


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

  • Prev by Date: Re: NSString initWithFormat and stringWith
  • Next by Date: Re: NSString initWithFormat and stringWith
  • Previous by thread: Re: workaround: stubborn text attributes in NSTextView
  • Next by thread: Fixing logged error that doesn't throw exception
  • Index(es):
    • Date
    • Thread