I am in he final step to design my application. It Basically consists of two tableviews plus other views. Each TableView has its own TableViewController class instance. What I would like to do is to activate the corresponding menu items when the user clicks one of the table view row. For example, I want to delete the file the user is currently selecting, so the file menu save is activated. But if he is not in the table view, I want to gray it out in the menu.
Therefore, I want to use First Responder. I added menu item, defined an action delete: in the First Responder and linked the menu item to that action. TableViewController is a subclass of NSViewController. In The TableViewController.m, I write in the init method (to insert the view controller in the responder's chain):
[self setView:_tableView];
[self setNextResponder:self.view];
[self.view.subviews enumerateObjectsUsingBlock:^(NSView *subview, NSUInteger idx, BOOL *stop) { [subview setNextResponder:self]; }];
But My method delete: doesn't get called! When the user click the tableview, it becomes the First Responder right? Then THe ViewController should receive the action. Otherwise, What is the First Responder and how to set it? I guess I'm missing something!
I found the solution to this problem. I just forgot to add a semicolon to my actions when I defined them in the First Responder.
SO I entered "delete" instead of "delete: " And just for this reason, my method -(void)delete:(id)sender was not called!
Thanks for your help anyway!