Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correct implementation of undoManagerForTextView



On 3 Mar, 2004, at 2:20 PM, Jeremy Dronfield wrote:

On 3 Mar 2004, at 9:08 pm, Dustin Voss wrote:

On 3 Mar, 2004, at 10:32 AM, Jeremy Dronfield wrote:

My app has two separate text views (one in the main window, another in a drawer). Each has its own separate delegate, and I want each to have its own undo manager. (So that they can separately trigger an Unsaved Changes warning.) The trouble is, I can't figure out the correct implementation of the NSTextView delegate method:

- (NSUndoManager *)undoManagerForTextView:(NSTextView *)aTextView
{
return (what?);
}

There's no illumination in the FM, and I'm further confused by a reference by Bill Cheeseman (Omni archives) to this as an NSWindow delegate method, which it clearly isn't.

I'm not using NSDocument. Each text view has a delegate (an NSObject subclass).

Secondly, there is an NSWindow delegate method that supplies an undo manager. If a text view needs an undo manager, it follows the responder chain, and will get one of these (in order):
* One returned by the NSTextView delegate's -undoManagerForTextView:

That's the one I want. The documentation tells me that "If you want a text view to have its own NSUndoManager (and not the windows), have the text views delegate implement undoManagerForTextView:, to return the NSUndoManager." What it doesn't tell me is how to implement this method. What do I return?

Well, I don't know why you don't want to use the window's and drawer's default undo manager, but given that you don't...

Just have the delegate objects instantiate an NSUndoController in the -init method, and return it.
_______________________________________________
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: 
 >Correct implementation of undoManagerForTextView (From: Jeremy Dronfield <email@hidden>)
 >Re: Correct implementation of undoManagerForTextView (From: Dustin Voss <email@hidden>)
 >Re: Correct implementation of undoManagerForTextView (From: Jeremy Dronfield <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.