Re: NSTextView undo/redo question
Re: NSTextView undo/redo question
- Subject: Re: NSTextView undo/redo question
- From: Brian Webster <email@hidden>
- Date: Sun, 19 Aug 2001 21:31:41 -0500
On Sunday, August 19, 2001, at 07:13 PM, cocoa-dev-
email@hidden wrote:
I have everything working without a separate undo manager in
about 10 lines
of code in my window controller, except for the fact that
removeAllActions
throws out the older pending actions along with the current
text field's
actions. It would be a lot easier if I could make
removeAllActionsForTarget:
work.
One approach that might help figure stuff out would be to create
a subclass of NSUndoManager and override the
registerUndoWithTarget:selector:object: and
prepareWithInvocationTarget: methods to print out NSLogs keeping
track of what undo actions are getting registered. You could at
least use this method to try to figure out what objects to pass
to removeAllActionsForTarget:.
There might also be a more general way: have your undo manager
subclass have a flag that you set when a text field begins or
ends editing. It could keep track of the targets that get
actions registered during editing, and then when the editing
ends, you could tell it to chuck all the actions for those
targets (and clear the list of targets).
A couple other ideas come to mind, but none of them seem any
more or less clean than anything else.
--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster