Re: Replacing contents of NSTextView...
Re: Replacing contents of NSTextView...
- Subject: Re: Replacing contents of NSTextView...
- From: Charles Jolley <email@hidden>
- Date: Thu, 20 Jun 2002 23:41:30 -0500
I suggest you take a look at using the NSTextStorage (well,
NSMutableAttributesString, of which NSTextStorage is a subclass) methods
directly. In particular look at:
- (void)replaceCharactersInRange:withString:
to set the text and
- (void)setAttributes:range:
to set the attributes to what you want them to be. There are lots of
variations on these themes so you can set the text to just what you
want. Be sure to sandwich all the calls you make to set your text
storage between -beginEditing and -endEditing.
-C
On Thursday, June 20, 2002, at 03:38 PM, Shoaib wrote:
I have a read-only NSTextView whose contents change constantly. I've
implemented the ability to show highlighted URLs in my NSTextView so
http links shows up as blue and underlined. I am using the underlying
NSTextStorage object to set the attributes of any URL strings in the
NSTextView.
Here's the problem:
If the contents of NSTextView are replaced (via NSTextView.setString),
it appears as if the attributes that were set for the previous contents
don't get overwritten. The NSTextStorage object appears to retain them.
So if originally my NSTextView had URLs string in it, and the new
contents don't have any, parts of the new content show up as blue and
underlined.
Do I need to call NSTextStorage.deleteCharactersInRange() to clear out
the attributes that were used by the previous contents everytime the
contents of NSTextView are replaced?
_______________________________________________
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.
_______________________________________________
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.