• 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
Re: strange quirk of UndoManager on NSTextView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >strange quirk of UndoManager on NSTextView? (From: Duncan Campbell <email@hidden>)

  • Prev by Date: Re: How do I save and restore a custom NSTextAttachmentCell?
  • Next by Date: Re: Capturing the stylus (ink input) in cocoa
  • Previous by thread: strange quirk of UndoManager on NSTextView?
  • Next by thread: Multiple help menus?
  • Index(es):
    • Date
    • Thread