Undo in NSTextView broken when runModalForWindow: ?
Undo in NSTextView broken when runModalForWindow: ?
- Subject: Undo in NSTextView broken when runModalForWindow: ?
- From: "Kirk A. Baker" <email@hidden>
- Date: Thu, 12 Feb 2004 17:17:36 -0800
I am having problems with undo/redo in a NSWindow that has a few
NSTextViews in it when the window is run in a modal loop.
The problem is easily reproduced by the following steps:
1) Enter some text in the first text field.
2) Enter some text in the second text field.
3) Type Command-Z to undo.
The result is that both text views clear themselves back to empty! It
should take two undos to do this.
Doing a redo puts the text back into both text fields simultaneously.
Performing the same set of operations in a non-modal window works
properly.
I have a sample xcode project available at:
<
http://www.xavagus.com/UndoText.sit>
I have looked at the NSTextView's NSUndoManager, dumped its _undoStack
and _redoStack, and I see why multiple edits are being undone/redone.
After each edit in a given text view, the undo object is not placed
between a beginUndoGrouping/endUndoGrouping pair. I see multiple text
undo objects after the begin, but there is no corresponding end group
object.
Even multiple edits within the same NSTextView do not work properly.
For instance if one types:
The quick fox jumps over the lazy dog.
and then clicks between 'quick' and 'fox' and then types:
brown
resulting in:
The quick brown fox jumps over the lazy dog.
and then one chooses undo, the whole sentence disappears, when one
would only expect the word 'brown' to disappear.
Has anyone seen this before? Any workarounds? I need this to work
properly in a modal dialog in our application.
Thank you,
-Kirk
_______________________________________________
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.