• 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
understanding NSTextView undo?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

understanding NSTextView undo?


  • Subject: understanding NSTextView undo?
  • From: Jim Correia <email@hidden>
  • Date: Sat, 28 Dec 2002 15:30:45 -0500

I'm trying to understand the undo mechanism in NSTextView.

There doesn't seem to be much documentation about the mechanics. If I've overlooked something important in the docs, can someone point me at it?

Question 1:

It seems that undo of typing is coalesced. This presents a problem for document applications because if you type, save, type, undo, it goes back to past the save point. Is there a way to force the coalescing to stop and start a new "group"? (This sounds like it should be a known bug, but unless someone confirms that it is, I'll file a bug..)

Project Builder seems to do something with an alert (and perhaps some other magic) to deal with this case.

TextEdit empties the undo stack on save, which while it works around the problem, is sort of lame.

Question 2:

How do I make transformations in NSTextView undoable? The docs just say "This method must be invoked at the start of any sequence of user-initiated editing changes...." but don't say that it handles the undo for you. Poking around in the debugger, it appears that it does (and further, if it returns yes, and I do not subsequently replace the text, it puts the text view in an inconsistent state.)

So, is making an action undoable as simple as

[textView shouldChangeTextInRange: range replacementString: string];
// do replacement
[textView didChangeText];

It seems to be that simple, but I want to make sure I'm not missing something important here.

Also, without providing my own implementation of shouldChangeTextInRange:replacementString: is it possible to affect the range that will be selected on redo?

Imagine that a transform inserts

[macroStart] macroText [marcoEnd]

and leaves macroText selected so that the user can type a replacement string.

But if I undo, then redo, the insertion point is left at the end of the inserted text. It would be nice if the selection range were preserved.

Thanks,
Jim

(I've got other questions about the text suite scripting, undo, and related things, but one step at a time..)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: understanding NSTextView undo?
      • From: Greg Titus <email@hidden>
  • Prev by Date: Re: Dec Dev tools: PB blows up under 10.2.3..?
  • Next by Date: (no subject)
  • Previous by thread: Re: Java Cocoa Table View DataSources
  • Next by thread: Re: understanding NSTextView undo?
  • Index(es):
    • Date
    • Thread