Xcode 4.3 will start producing mainmenu.xib
I look at that mainmenu.xib
It has an object named Main Menu
I go and look at what are the menu points too
Menu Item - Show All for example, link to unhideAllApplications:
I try to find where is unhideAllApplications defined but can't find any. The outlet window says that it's linked to the first responder.
It is linked to first responder
I check the class of first responder, I can't find anything either
The file owner of mainmenu.xib, for example, is an object of class NSApplication.
What's the class of First Responder? There is nothing mentioned in the class view
Curiously there are 3 objects in mainmenu.xib and Application and Owner are both of type NSApplication. Go figure
First responder is the currently focused UI element. It changes whenever the focus moves.
The next responder is usually that element's parent, the one after is this parent's parent, and so on, ending with window content view, window, application and maybe application's delegate.
Every event is passed down the chain with each responder either handling it or passing to the next responder.
For example, unhideAllApplications
is defined in NSApplication
. When this action is generated, each of the responders in the current chain will try it until it is eventually handled by the application object. The difference from sending to the application directly is that other objects will have a chance to intercept it.