views:

39

answers:

1

Hi,

I have a window with multiple views (they all subclass NSView and there is always only one visible) on which i draw paths. I'd like to have an NSUndoManager for each view, but obviously they all have the same NSUndoManager, coming from the NSWindow.

Is this even possible?

Thx xonic

A: 

Check out the NSWindowDelegate method windowWillReturnUndoManager:. You should be able to use this to return the correct undo manager for the current view.

Alex
Thanks for your reply. From the docs I understand that I can advise th delegate that the undo manager has been requested and if the delegate doesn't implement windowWillReturnUndomanager, then a new undo manager will be created for the window. Still I can't see how this can be useful for me. I need a different undo manager for each view in my window, not one for all. Is there something I just don't get?
xon1c
I don't think the undo manager is cached, so `windowWillReturnUndoManager:` should be called quite frequently, giving you an opportunity to return the "current" undo manager.
Alex