Re: NSTextView: How do you allow highlighted (selected) areas to change vs the ENTIRE view?
Re: NSTextView: How do you allow highlighted (selected) areas to change vs the ENTIRE view?
- Subject: Re: NSTextView: How do you allow highlighted (selected) areas to change vs the ENTIRE view?
- From: Douglas Davidson <email@hidden>
- Date: Wed, 25 Jan 2006 14:47:18 -0800
On Jan 25, 2006, at 2:35 PM, Frederick C. Lee wrote:
How do you allow a highlighted/selected area within an entire
NSTextView to change versus solely the entire NSTextView?
I can't change a highlighted area within a NSTextView; only the
ENTIRE view is changed (color, font characteristic, etc.).
Is there a flag or something to set?
Generally speaking, you obtain the rangesForUserTextChange,
rangesForUserCharacterAttributeChange, or
rangesForUserParagraphAttributeChange, depending on what you're
doing, and then modify those ranges in the text storage.
Sequences of changes should be surrounded by beginEditing/endEditing
calls. If the change represents user action, it should be preceded
by a call to shouldChangeTextInRanges:replacementStrings: (and fail
if that returns NO) and be followed by a call to textDidChange. For
many user actions, it's also appropriate to change the typing
attributes.
If that sounds a bit complicated, you can always make use of
changeAttributes:, supplying a sender that implements
convertAttributes: to behave as described in the NSFontManager
documentation. That will handle all of the above for you automatically.
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