Re: How to validate the Undo menu item?
Re: How to validate the Undo menu item?
- Subject: Re: How to validate the Undo menu item?
- From: Dustin Voss <email@hidden>
- Date: Mon, 5 Aug 2002 00:06:52 -0700
On Tuesday, April 23, 2002, at 12:04 PM, Bill Cheeseman wrote:
How do I validate the Undo menu item so that it will be disabled in
certain
circumstances? The usual validateMenuItem: technique doesn't seem to work
very well with the Undo menu item.
<snippage of the app's architecture>
I don't see any way my undo: method can tell Cocoa to continue walking the
responder chain to find the "real" undo method. Besides, undo doesn't seem
to work that way; it looks like it calls performSelector: on Cocoa's
private
undo stack to call the registered undo action on the top of the stack. But
if that's the case, where does Interface Builder find the undo: action
that
comes pre-connected to First Responder in the document-based application
template, anyway, and what does it do? This is all very confusing.
Well, I've been trying to get undo working in a preference pane (not fun,
since the NSPreferencePane class doesn't pass along
windowWillReturnUndoManager:), so I've also wondered where undo:'s
implementation is.
Assuming the AppKit validates the "Undo" menu item in the usual way, with
the undo: action, it must be somewhere in this responder chain:
Control/View → View → Window → Window Delegate → App → App Delegate
So I checked NSView, NSTextView, NSResponder, NSWindow, and NSApplication,
and found that NSWindow is the one that implements the undo: method. (I
used respondsToSelector: and instancesRespondToSelector:.)
Of course, the NSWindow docs and header file say nothing about undo:. I
guess it's a private API for NSWindow, which is why it doesn't show up in
the header file, but I would have liked to have known about it. I'm torn
whether to report this as a doc bug or not. What do you guys think?
--
Dustin
_______________________________________________
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.