• 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: NSTextView and limiting text attributes via delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView and limiting text attributes via delegate


  • Subject: Re: NSTextView and limiting text attributes via delegate
  • From: Scott Lehman <email@hidden>
  • Date: Fri, 3 Feb 2006 15:42:44 -0800 (PST)

Ah, I see.

Would subclassing NSTextView also be a viable option?
It seems like the changeAttributes: and
pasteAsRichText: might provide the hooks to do some
processing as well.

I clearly have some more reading on the text system to
do :)

Thanks,

Scott


--- Douglas Davidson <email@hidden> wrote:

>
> On Feb 3, 2006, at 3:01 PM, Scott Lehman wrote:
>
> > I have an NSTextView, but want to limit the kinds
> of
> > formatting that can be used in it.  The new
> delegate
> > method
> >
> textView:shouldChangeTypingAttributes:toAttributes:
> > caught my eye as a good place to start, however it
> > doesn't seem to do what I expect.
> >
>
> The typing attributes are the attributes that will
> be used for the
> next character that is typed.  Try bringing up an
> empty document in
> TextEdit, hitting cmd-U, and typing something; it
> should appear
> underlined.  Your implementation of the delegate
> method should be
> able to prevent that.
>
> However, you also want to control changes to the
> text.  You can use
> textView:shouldChangeTextInRange:replacementString:
> to be notified of
> this.  Try making a note of the range in this
> method--modifying its
> length based on the replacement string's if there is
> one--and then in
> textDidChange: you can examine the changed text and
> remove any
> unwanted attributes.
>
> Another alternative would be to use a custom text
> storage, not to
> change the storage mechanism, but to override
> attribute fixing.
> Working at the text view delegate level lets you
> control user-
> initiated changes.  At the text storage level, you
> can modify all
> changes, programmatic or user-driven.
>
> Douglas Davidson
>
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 _______________________________________________
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

  • Follow-Ups:
    • Re: NSTextView and limiting text attributes via delegate
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: NSTextView and limiting text attributes via delegate (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: Custom NSView doesn't redraw itself properly after use of NSPopUpButton
  • Next by Date: Re: NSTextView and limiting text attributes via delegate
  • Previous by thread: Re: NSTextView and limiting text attributes via delegate
  • Next by thread: Re: NSTextView and limiting text attributes via delegate
  • Index(es):
    • Date
    • Thread