Lost between objects, first responder, file's owner…

Hello,

In my first Document-based app, I have the problem some of you have maybe experienced – and resolved:

I have menu items which drive the behavior of document features (say “print picture” when the current doc displays a picture).

How can I bind my command to the correct object? I suppose this is made via the single instance of First Responder (because my handlers are listed into the connection window) but when I switch to the document xib, the connection is not done. In fact, my menu commands stay disabled (even when a doc capable to execute the commands is active).

Do I have to add actions to the First Responder? Which one (if there are many)? I’m sure the solution is simple, but I’m a bit lost now.

Regards,

Yes.

Correct. What you are making is called a nil-targeted action; it’s not connected to any particular target, but rather traverses the responder chain until it finds an object that implements the action.

That doesn’t mean the connection has not been made. Have a look at the section Responder Chain for Action Messages.