Re: NSUndoManager - clearing a single 'redo' - Now->doesn't respond to removeAllActionsWithTarget
Re: NSUndoManager - clearing a single 'redo' - Now->doesn't respond to removeAllActionsWithTarget
- Subject: Re: NSUndoManager - clearing a single 'redo' - Now->doesn't respond to removeAllActionsWithTarget
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 09 Dec 2002 20:37:04 -0500
on 02-12-09 7:14 PM, Bruce Veazie at email@hidden wrote:
>
I didn't try pfutzing with NSUndoManager itself. It occurred to me that
>
I could create a dummy target for that one undo and remove all actions
>
for that dummy target when the undo is performed. That should preserve
>
the documents other pending undo's and redo's.
That's a very clever idea. It didn't occur to me. But....
>
However, the 'Edit' menu now shows 'redo Add object.' Clicking it
>
doesn't appear to perform any action but 'Add object' is obligingly
>
moved to the undo stack to display 'Undo Add object,' which doesn't do
>
anything either.
This is built-in undo manager behavior. I was never able to find a way
around it. You have to find a trick that can live with this behavior.
>
I tried both the 'registerUndo' and 'prepareWithInvocation' methods as
>
well as throwing in some begin- and endgroupings for good measure in
>
various combinations as exasperation increased. I also tried targeting
>
the document method itself in the undo and performed a
>
'removeAllActionsForTarget:self' when the object was deleted.
>
>
To no avail. The 'Add object' action stays in the Edit menu.
Yes. I tried to find ways around this for quite a long time. To no avail.
>
Am I missing the use of the 'removeAllActionsForTarget' method or
>
perhaps some sort of menu item validation call? Any help?
I don't think you're missing anything. I barked up the same tree for a long
time, and finally gave up. When I eventually turned to the undo manager
notifications, and the idea of just pretending like the user had done
whatever it takes to get rid of the unwanted item on the undo or redo stack,
it finally all came together. In the end, the code is very short and simple.
The key, as I said, was that registering a new undo action on the same
control was the only way to get the damn action out of both stacks into some
other universe where I don't care what it does.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
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.