-undoManagerForTextView: question
-undoManagerForTextView: question
- Subject: -undoManagerForTextView: question
- From: Darrin Cardani <email@hidden>
- Date: Fri, 2 Apr 2004 15:29:31 -0600
I have a window with an NSTableView in it. I have created a custom
subclass of NSTextView, and I create an object of this class as the
field editor for the NSTableView. My document is the delegate of the
window, and it implements the -windowWillReturnFieldEditor:toObject:
method so it can return an instance of the custom text view to use in
editing the table. This works fine.
I'm now dealing with the same problem that everyone appears to run
into with undo. Namely, while the user is typing in the text view,
they get the "Undo Typing" item in the undo menu. Once they commit
the edit, the document is sent a
-tableView:setObjectValue:forTableColumn:row: message, and it updates
the data and puts the update on the undo stack. Now there is a "Undo
update" item on the top of the stack with "Undo Typing" right below
it. If the user undoes the update, Undo Typing shows up in the undo
menu, but selecting it does nothing, because the item is not being
edited anymore.
I thought if I created an undo manager specifically for the text view
that would solve the problem. I did that, then set the document to be
the delegate of the text view. The document then implements
-undoManagerForTextView: so it can return the custom undo manager.
However, its -undoManagerForTextView: method is never called. Why not?
As a workaround, I've implemented a -windowWillReturnUndoManager:
method in my document. Since it is the delegate of the text field,
when the user starts entering data in the text field, the document's
-controlTextDidBeginEditing: method is called, and I note that the
user is editing text in the custom editor. In my document's
-windowWillReturnUndoManager: method, if the user is currently
editing text, I return the textView's undo manager, otherwise I
return the regular undo manager.
This results in the behavior I want, but it seems like I shouldn't
have to go through all of this to implement it. If my
-undoManagerForTextView: was being called, I wouldn't have to keep
track of which undo manager to return. So did I do something wrong
here, or what? Why is -undoManagerForTextView: never called? And is
what I did the usual way of solving this problem?
Thanks,
Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<
http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
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.