In my app's window there is an NSTextView, a place in which to enter notes associated with a selected object. Currently, when the user is finished editing those notes and switches to a different view (like clicking in another text area), I capture that edit session and store the new notes by calling -setNotes: on that object; this creates an Undo action, allowing the user to undo the entire edit session in one fell swoop.

I had initially turned on the "Undo" flag in IB for that text view, so that the user could undo (and redo) "sub-edits" while the edit session was in progress ("Undo Typing" is pushed onto the Undo stack by the text view, apparently), while my custom Undo action pushed onto the Undo stack would undo the entire edit session itself ("Undo Edit Notes").

I find when I do this, with the text view's Undo flag enabled, there is some "zombie" undo action left on the Undo stack, that does nothing, and doesn't go away.

Here's the entire process:

1. Select and object and start typing in the Notes field
2. The Edit menu contains "Undo Typing", and does just that--reverts the typing while I'm in still in that text view. 3. If I select "Undo Typing", that works, and now the Edit menu contains "Redo Typing" (there is no Undo available, and it is disabled). Redo works, and the Edit menu contains "Undo Typing" (and Redo is disabled). 4. With changes in the text view, I click a different text area in the window; this action ultimately causes the object's -setNotes: method to be called, in which I set up the Undo action with the current notes and then update the object with the new notes.
5. The Edit menu now contains "Undo Edit Notes" (Redo is disabled).
6. If I select "Undo Edit Notes", the change is reverted; the Edit menu now contains "Redo Edit Notes", but also an enabled "Undo" item. 7. At this point, I can select "Undo" as long as I have the patience to continue doing so. Nothing (apparent) happens, I never get to the end of the Undo stack, and *my* "Redo Edit Notes" Undo action remains available. 8. I can select my "Redo Edit Notes", and the right thing happens; the Edit menu goes back to "Undo Edit Notes" (Redo is disabled) and selecting it again takes me back to step 7, ad infinitum.

I can only assume this anonymous "Undo" action is left over from the NSTextView undo stack (since using that is the only way I can get this to appear). Turning off the Undo flag for that text view in IB makes this all go away. I s'pose I could liberally interpret the customer's "specification" to make my custom Undo action the "right" thing to do (and eliminate the undo ability whilst editing the field), but that just doesn't sit right with me.

But I haven't been able to figure out why this anonymous Undo action is left on the stack, or a good away to get rid of it, or even figure out what happens when I select it.

Any ideas?

Thanks!
randy
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to