• 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: NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.


  • Subject: Re: NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.
  • From: James DiPalma <email@hidden>
  • Date: Thu, 17 Jun 2004 01:31:46 -0700

Implement -windowWillReturnUndoManager: in your window's delegate?


I have alloc/init-ed NSUndoManagers and used them outside of an NSDocument context. I suspect that your "Undo" menu item does not target an object that is using your model's undo manager.

On Jun 16, 2004, at 2:26 PM, Frederick C. Lee wrote:
PROBLEM: I don't see "Currency Name" associated with the 'Undo' (e.g.,
"Undo Currency Name") Edit-Menu item. I've reversed-engineered

Is that menu item enabled? does it undo your "Currency Name" changes?

However, I'm not using NSDocument in my appl so I have to create an
'undoManager' instance within the following paradigm:

GUI <--> MyController <--> CountryModel {controller:
source of NSUndoManager; Model: setting & registering an Undo instance}

All your code looks correct, but I don't see how your undo manager is getting associated with your undo menu's target, so I'm unsure if your undo menu will even undo (actually, I would be surprised if it did).

A default undo: menu item is connected to first responder, which will likely target an NSWindow who can get its undo manager from its delegate (if your window has no delegate or this delegate does not implement this method, it will create an undo manager that is different from your model's undo manager):

- (NSUndoManager*) windowWillReturnUndoManager:(id)sender;

Reverse-Engineering the Doc example:
I overrid the NSDocument's undoManager in the document example using
[[NSUndoManager alloc]init] and lost the 'setActionName' effect.

Not sure why you lost action names here. If an NSWindow has a window controller, and this window controller has a document, that document's undo manager will get returned by this window's -undoManager method. I am forgetting how this path of getting an undo manager interacts with windowWillReturnUndoManager: and a casual glance at documentation does not mention which takes precedence (a simple test would answer this question, but its late -- interestingly, I didn't notice any documentation that suggested these two methods could conflict with each other).

Somehow, merely doing a NSUndoManager initiation within the controller
isn't enough.
I tried locally-defining undoManager (w/in CountryModel):
undoManager = [[NSUndoManager alloc]init]; // locally defined.

Now you have two undo managers? I don't understand what you are trying to do here; alloc/initing an undo manager within your model is fine, but it still needs to get pushed into an object that can be targeted by your menu item (model's don't usually get targeted by menus, nor get inserted into a responder chain).



-jim
_______________________________________________
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: 
 >NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name. (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: Re: Releasing memory
  • Next by Date: Re: Color of string with link attribute
  • Previous by thread: Re: NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.
  • Next by thread: Color of string with link attribute
  • Index(es):
    • Date
    • Thread