[Openmcl-devel] The File Menu

mikel evins mevins at me.com
Sun Jan 24 00:47:03 PST 2010


On Jan 23, 2010, at 11:29 PM, Ron Garret wrote:

> Is it possible to change the behavior of items in the File menu?  Is  
> it straightforward?  I want to intercept the SAVE and REVERT items  
> and hook them up to a revision control system.  I tried to reverse  
> engineer the menu but ran into a roadblock when the action selector  
> was just a foreign pointer with no hint as to what it was pointing  
> at.  Is the File menu managed by Lisp at all, or is all of its  
> functionality provided by Cocoa?

The standard menu items send standard events that get handled by  
standard methods. Save calls the document's saveDocument: method, and  
revert calls its revertDocumentToSaved: method (assuming you're using  
document objects; actually, if I recall correctly, they send the  
messages to the first responder, which, in the case of a document- 
based app will be an instance of NSDocument or a subclass).

The canonical and therefore easy way to modify their behavior is to  
create a custom NSDocument subclass and write methods on those  
messages. You can find details about them at:

http://developer.apple.com/mac/library/documentation/cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/Reference/Reference.html

There might also be a delegate protocol for handling them, in which  
case a possibly even easier way would be to provide methods on the  
application delegate, but I don't remember that for sure.

--me



More information about the Openmcl-devel mailing list