• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Undo/redo in sheets?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undo/redo in sheets?


  • Subject: Re: Undo/redo in sheets?
  • From: Pete Yandell <email@hidden>
  • Date: Wed, 18 Sep 2002 10:00:13 +1000

On Monday, September 16, 2002, at 08:52 AM, Dustin Voss wrote:

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.

No, I'm using the undo manager from my NSDocument instance.

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.

Yes, both the document window and the panel are getting the undo manager via windowWillReturnUndoManager. The undo events that I register in the panel are ending up in that undo manager's stack and, when I close the panel, I can happily choose undo and the actions performed in the panel will be undone. The only problem is that the undo and redo menu items are greyed out while the panel is open.

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.

That's what I'll try next. It seems silly though...why are the items greyed out in the first place? Why do I have to do extra work to get what should be (IMHO) the default behaviour?

Pete Yandell
http://pete.yandell.com/
_______________________________________________
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.

References: 
 >Re: Undo/redo in sheets? (From: Dustin Voss <email@hidden>)

  • Prev by Date: Re: init code in ApplicationNotifications/awakeFromNib
  • Next by Date: Re: init code in ApplicationNotifications/awakeFromNib
  • Previous by thread: Re: Undo/redo in sheets?
  • Next by thread: Transparency Problems
  • Index(es):
    • Date
    • Thread