Some questions
Some questions
- Subject: Some questions
- From: Dustin Voss <email@hidden>
- Date: Mon, 5 Aug 2002 00:07:10 -0700
Let's say you type in an NSTextView control, and then click an "Undo"
button in the same window (so that the key and main windows are the same).
As I understand it, each NSResponder handles the "undo:" action by calling
the "undoManager" method on each responder in the chain:
Text View → View → Window → App
Of these, only the text view and the window are going to return an
NSUndoManager. NSTextView will ask its delegate, then NSWindow will also
ask its delegate, and then, if NSWindow's delegate doesn't return an
NSUndoManager, the window will make one. NSApp won't even be queried. So
the only sources of an NSUndoManager are, in order:
Text View Delegate → Window Delegate → Window
Once an NSResponder gets an NSUndoManager, it calls the manager's "undo:"
method.
Okay, there's my understanding. Now, how does the menu get updated? Well,
let's start by assuming that it follows the usual validation path. The
menu will update itself every time you type a character. I checked the
"Undo" menu item; it has no explicit target. So NSMenu will look for an
object that implements "undo:" along this responder chain:
Text View → View → Window → Window Delegate → App → App Delegate
It will find the "undo:" method in NSWindow. This question is tangentially
dealt with in a thread titled "How to validate the Undo menu item?".
_______________________________________________
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.