• 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 for non-document based applications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undo for non-document based applications


  • Subject: Re: Undo for non-document based applications
  • From: "K. Darcy Otto" <email@hidden>
  • Date: Thu, 11 Dec 2008 21:10:21 -0800

On 10-Dec-08, at 8:54 PM, Graham Cox wrote:


On 11 Dec 2008, at 2:53 pm, K. Darcy Otto wrote:

I'm trying to get undo working with an application that is not document-based. So far, I think I have got the operation on the stack, but have yet to get the menu reflecting this. What I have so far is the initialisation of undoMan (in init:), but when I get the operation onto the stack (by the last method, observeValueForKeyPath:), the undo menu item does not get activated.

If I add the line:



undoMan = [[NSUndoManager alloc] init];


To ensure that the menu is correctly linked to this undo manager, you need to use:

-windowWillReturnUndoManager:

which is a delegate method of NSWindow. If you set your AppController to be the window's delegate and implement this method to return undoMan, you should find the menu works as you want.

That solves the problem. I just made AppController the delegate, as you suggested, and then added this code:


- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)sender
{
   return undoMan;
}

And it worked like a charm. Thank you!
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Undo for non-document based applications (From: "K. Darcy Otto" <email@hidden>)
 >Re: Undo for non-document based applications (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Looking for info on creating Plugins/Modules
  • Next by Date: odd "image not found"
  • Previous by thread: Re: Undo for non-document based applications
  • Next by thread: Prolem with CalCalendar programming
  • Index(es):
    • Date
    • Thread