Reputation: 274
OK, I am having a project having many xib's and each xib contains many nswindows.
I need to use a keyboard shortcut to save for each of the window.
Do I need to create muliple mainMenu NSMenuItems for each of XIB. But another problem is there as How a single Cmd+S will know which window is in focus and how my method will get invoked.
Upvotes: 1
Views: 300
Reputation: 46543
No You need not to make multiple NSMenuItems.
The one coming with mainMenu.xib serves this purpose.
Make an IBAction of File->Save
menu and use it as :
- (IBAction)saveMenu:(id)sender {
NSWindow *currentWindow=[NSApp keyWindow];
NSLog(@"this is key window : %@", currentWindow.title);
}
This will give you the active window.
In each of the controllers, you need to override
- (void)saveDocument:(id)sender;
And bind it using IB.
Upvotes: 2