Re: Modifying the text attributes applied to an NSTextView
Re: Modifying the text attributes applied to an NSTextView
- Subject: Re: Modifying the text attributes applied to an NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Tue, 30 Mar 2004 14:37:06 -0800
On Mar 30, 2004, at 1:39 PM, Scott Thompson wrote:
I've got a text view that is a "Rich Edit" view. What I'd like to do
is allow pretty much the full range of text editing features for the
text in that view EXCEPT no font size changes allowed (for example,
you get 12 point text and you're going to like it!). Beyond that the
user should feel free to change the font, the color etc... etc....
What I think I'd like to do is intercept the attributes before they
are applied to the TextStorage, change any fonts entered so that they
are 12 pt, then allow the attribute change to proceed as normal.
What I would suggest is that you allow the change to proceed as normal,
then intervene afterwards to constrain the fonts as you desire. That
will help you in the case that e.g. the user pastes in 24-point text.
You should be able to do this with a combination of should-change and
did-change delegate methods--for example, you can make a note of the
range that is changing in the should-change method and then use that
information in the did-change method. You will have to modify the
range to take into account any change in length if there is a
replacement string and it is not the same length as the range being
modified.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.