• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
strange quirk of UndoManager on NSTextView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: strange quirk of UndoManager on NSTextView?
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Loadable bundles and version control
  • Next by Date: Re: Loadable bundles and version control
  • Previous by thread: Re: Loadable bundles and version control
  • Next by thread: Re: strange quirk of UndoManager on NSTextView?
  • Index(es):
    • Date
    • Thread