| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
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..)
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.
| References: | |
| >understanding NSTextView undo? (From: Jim Correia <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.