Re: insertText
Re: insertText
- Subject: Re: insertText
- From: Philip Dow <email@hidden>
- Date: Wed, 4 Jan 2006 12:35:14 +0100
It may also be necessary to surround that
replaceCharactersInRange:withString: method with
[[textView textStorage] beginEditing];
[[textView textStorage] endEditing];
Those should ensure a clean attributed string, whatever your changes
may be. If the NSTextView instance is editable, you should also call
[textView shouldChangeTextInRange:[textView rangeForUserTextChange]
replacementString:someString]
and proceed only if that method returns true. As far as I can tell,
that method also ensures that your changes are registered with the
undo mechanism, although I'm not sure if does more or less.
-Phil
On Jan 4, 2006, at 12:05 PM, Andreas Mayer wrote:
Am 04.01.2006 um 10:15 Uhr schrieb Kenny Millar:
Do I use [textView string], to get the existing contents,
manipulate them
manually and then [textView setString] to send them back, or is
there a more
elegant method?
Yes, there is.
[textView textStorage] returns an NSTextStorage which is a subclass
of NSMutableAttributedString.
So you can do:
[[textView textStorage] replaceCharactersInRange:range
withString:string];
Andreas
_______________________________________________
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
_______________________________________________
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