I'm implementing a Java app that includes an Undo/Redo stack. I've noticed that some apps (such as TextEdit on Mac OS X) let you choose "Undo Typing" from the Edit Menu after typing some text. I'd like to implement that sort of thing into my app as well, but I'm having a really hard time finding guidelines about how it should behave.
With some trial and error, my best guess about how TextEdit's Undo Typing behaves is:
- When the user types a new character (or types the delete key), merge it into the previous Undo Typing item if one is at the top of the Undo stack, unless one of the following situations occurs
- Always create a new Undo Typing item after the user continues to type after at least 15 seconds of inactivity
- Always create a new Undo Typing item after the user is typing for an extended period of time and some condition is met (couldn't figure out if this was time based or character count based).
- Always create a new Undo Typing item when any text is selected and then deleted or overwritten (selecting text, not making a change, then returning to the original insertion point and continuing to type does not trigger this)
In practice, Apple's strategy seems to work (at least it works for me when I type), but as noted by the last point, I haven't really been able to figure out the rules. Also, it seems like other programs follow different rules, such as Microsoft Word. Google has not turned up a defined list of rules for any implementation of Undo Typing and I haven't come across any best practices for how it should behave. So how should it behave? Or is it just up to the whims of the programmer?
EDIT: Just to clarify, I'm not interested in implementation details right now. I'm especially curious as to whether or not an authoritative reference (e.g. best practices or user interface document) exists describing this or a description of how it is implemented across multiple products.
124<delete>3
, then undoing and redoing it results in123
. I guess the advantage of this is that it results in the user's final state of the text, somewhat like the above suggestion. – Thunderforge Feb 27 '13 at 04:07