I'm working on a Cocoa application that will eventually only have 2 items in the main window menu. Not included in these items is the 'Edit' menu item. Is it possible to add all the functionality of the 'Edit' item to the application without having 'Edit'? I'm talking about all of the copy, paste, undo etc.... I know one could do this by adding keyboard listeners in window controllers, but I'm wondering if this can be done any other way?
The reason I want to do it differently is that I still want to use these commands in the native About window. That window doesn't have a controller (that I know of) that a listener could be added to. If anyone has alternative ideas about how to do this I'm all ears.
Yes. The edit menu items are just sending arbitrary "messages" to the "responder chain".
[[NSApplication sharedApplication] sendAction:@selector(copy:) to:nil from:self];
If you look at the event menu items inside interface builder, you can see the list of selectors being sent.
From the documentation:
If aTarget is nil, sharedApplication looks for an object that can respond to the message—that is, an object that implements a method matching anAction. It begins with the first responder of the key window. If the first responder can’t respond, it tries the first responder’s next responder and continues following next responder links up the responder chain. If none of the objects in the key window’s responder chain can handle the message, sharedApplication attempts to send the message to the key window’s delegate.
More details are here: