strange quirk of UndoManager on NSTextView?
strange quirk of UndoManager on NSTextView?
- Subject: strange quirk of UndoManager on NSTextView?
- From: Duncan Campbell <email@hidden>
- Date: Thu, 17 Nov 2005 18:27:33 +1100
Hi folks.
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];
2. Type some characters directly AFTER my new text attachment.
3. Then put the text back:
[[myTextView textStorage] replaceCharactersInRange:myRange
withAttributedString:originalText];
and then perform an undo, the undo happens at the location that
existed when the attachment was in place rather than the correct one
(which is now more chars to right - depending on the length of the
text that was in the attachment) - the outcome of this being that
chars that were inside the attachent are undone (deleted).
I assume that this is because the UndoManager uses the location of
the text to decide undo/redo, but does anyone have any advice on how
I can go about solving this, other than implementing my own undo?
Cheers.
Duncan.
_______________________________________________
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