• 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
custom text data and undo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

custom text data and undo


  • Subject: custom text data and undo
  • From: Jerry <email@hidden>
  • Date: Mon, 5 Dec 2005 14:05:26 +0100

I have written a specialized word processor that requires extra data to be associated with the text. Using text attributes to represent the data doesn't work out because the range of the associated data can be zero in length (for instance, when no text has been typed yet), and using text attachments doesn't always work because the range of the associated data can be greater than one.

I was happy to see that there were methods in NSTextView to add and remove custom data from the pasteboard. I overrode the four required methods and hey presto when the user selects "cut" all the data is moved to the pasteboard successfully and removed from the associated NSTextStorage. Everything is fine...

... until the user hits undo. D'oh! Undo seems to be implemented entirely based on private methods and undocumented classes. If NSTypingUndo (I may be misremembering that name) even called attributedSubstringFromRange: I could work something out, but instead it invokes (at least in Tiger) _undoRedoAttributedSubstringFromRange:. Overriding that is just begging for trouble down the road, and I have no idea if it would even work at all in Panther, which I still support.

So now I have a category in my TextView subclass that implements all the cut, copy, paste, delete, and dragging functionality, just so I can have undo work properly. I have spent a lot of time on the code, and I will have to spend more time yet tweaking it. I have also spent a week here and there trying to get rid of it. There is nothing I would like more than to throw the whole dang thing away.

I think I must be missing something, because the pasteboard functionality is needlessly limited in utility without a corresponding undo capability. It just doesn't make sense to have one without the other.

Thanks for any pointers you can provide.

Jerry Seeger
Jer's Software Hut
http://jerssoftwarehut.com

_______________________________________________
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: custom text data and undo
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: custom text data and undo
  • Next by Date: Re: Bindings and Collections
  • Previous by thread: custom text data and undo
  • Next by thread: Re: custom text data and undo
  • Index(es):
    • Date
    • Thread