Re: Undo/redo in sheets?
Re: Undo/redo in sheets?
- Subject: Re: Undo/redo in sheets?
- From: Dustin Voss <email@hidden>
- Date: Sun, 15 Sep 2002 15:52:08 -0700
On Saturday, September 14, 2002, at 07:41 PM, Pete Yandell wrote:
I dug up on old thread on this topic in the archives
(http://lists.apple.com/archives/cocoa-dev/2001/Oct/08/
undoinasheetnotakers.txt), but it didn't seem to have any answers.
The problem is this: whenever I have a sheet open, the Undo and Redo
menu items are disabled.
My sheet allows editing of a list of items in an NSTableView, and I
want to be able to allow undo for creation of new items, deletion of
items, renaming of items, etc.
I can happily register the events with the undo manager, and they can
be undone after the sheet closes, but not while it's open. How can I
convince the system to re-enable the Undo and Redo menu items while
the sheet is visible?
Are you using the default NSUndoManager? If so, that might be the
problem. The default NSUndoManager is owned by the NSWindow instance. A
sheet and its document window are different NSWindow instances, so they
have different default NSUndoManagers.
If you are supplying an undo manager to your document window using the
"windowWillReturnUndoManager:" delegate method, is that delegate
getting called when your sheet is up? If so, then AFAIK, the "Undo"
menu item should be working.
If you aren't using the default undo manager, and the delegate method
isn't being called, then you can always handle the "Undo" menu item
yourself. Just implement the "undo:" and "validateMenuItem:" methods in
your sheet's controller to operate the "Undo" menu item. NSUndoManager
has all the necessary functionality.
--
Dustin
_______________________________________________
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.