| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
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.
Firstly, the undo manager is not in charge of unsaved changes warnings. Your model should keep track of this itself.
NSDocument keeps track by observing the NSUndoManager it maintains, and other parts of the framework check with NSDocument to see if there are unsaved changes.
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:
Thirdly, depending on how your app is laid out, are you sure you want two undo managers? Remember that the undo manager controls the undo stack. Let's say the user makes a change A in the first text view, change B in the second, and change C in the first. With two undo managers, he will be be able to undo C then A when he is in the first text view, but if he switches to the second, he will only be able to undo B.
| References: | |
| >Correct implementation of undoManagerForTextView (From: Jeremy Dronfield <email@hidden>) | |
| >Re: Correct implementation of undoManagerForTextView (From: Dustin Voss <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.