Re: strange quirk of UndoManager on NSTextView?
Re: strange quirk of UndoManager on NSTextView?
- Subject: Re: strange quirk of UndoManager on NSTextView?
- From: Douglas Davidson <email@hidden>
- Date: Thu, 17 Nov 2005 09:48:01 -0800
On Nov 16, 2005, at 11:27 PM, Duncan Campbell wrote:
I'm playing around with NSTextView and an NSTextAttachment subclass
to replace ranges of text with graphics.
I have things working quite well , however, I've run into a problem
with the way undo works with NSTextView:
if I:
1. Replace a range:
NSAttributedString *collapsed = [NSAttributedString
attributedStringWithAttachment:myTextAttachmentSubClass];
[[myTextView textStorage] replaceCharactersInRange:myRange
withAttributedString:collapsed];
Modifications to the text storage that are intended to be undoable
must notify the text view so that the undo machinery can be
involved. To do this, call -[NSTextView
shouldChangeTextInRanges:replacementStrings:] or -[NSTextView
shouldChangeTextInRange:replacementString:] before the change; if the
return value is YES, make the change and then call -[NSTextView
didChangeText]. See the documentation on these methods for more
information. A single change can be more than a single modification
call to NSTextStorage; shouldChangeTextInRange:replacementStrings:
allows for a fairly large range of modifications to be reported as a
single change.
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