0

Short answer is inside the title :)

Explaining: in my MainMenu.xib I have only the Main Menu of the application, that must be same for all NSWindows I open. There is one particular NSWindowController that has, let me say, all answers about when menu item must be enabled (via cases on selector in validateUserInterfaceItem) and what to do with all actions. When NSWindow associated with that NSWindowController is currently focused, there is no problem, but as I focus on another NSWindow all menus are grayed.

I have this flow now: MainMenu is created by reference to it as Main nib into info.plist, then AppDelegate do some init stuff and create MainWinController with MainWindow, at some point MainWinController creates 1+ DetailsWinController with DetailsWindow. AppDelegate manage my custom menu by calling each time functions from MainWinController.

So, how can I force the responder chain to query always that particular NSWindowController (MainWinController)?

Andriy M
  • 76,112
  • 17
  • 94
  • 154
Shebuka
  • 3,148
  • 1
  • 26
  • 43

1 Answers1

0

You don't give many details to go on, and it isn't clear what you are trying to achieve.

My first reaction is that if you want share Menu items why are you creating multiple windows rather than Views within your MainWindow?

Assuming both your MainWindow and DetailsWindow implement the same selectors you could direct Menu Actions to the First Responder

To add the DetailsWinController in the InterfaceBuilder drag an NSObject from the Object Library, then in Identity Inspector change its class to your DetailsWinController class.

If your Main Menu has different items for the DetailsWindow just connect these to the actions in that instance.

NOTE if you so this you should NOT create the DetailsWinController in code. If you really want to do this in code you will need to add actions and targets to your menu in code.

Milliways
  • 1,265
  • 1
  • 12
  • 26
  • Each new DetailsWindow created by an user action in MainWindow has it's own DetailsWinController. I can have even 50 DetailsWindow at time. How can i use a View instead of Window in this case? – Shebuka Jul 17 '12 at 08:38
  • I don't want to implement all selectors in DetailsWinController and other XxxWinControllers that can be created by MainWinController, because they will be all a redirects to MainWindowController... So for now i'v implemented all selectors in AppDelegate and MainWinController, so when DetailsWin is active AppDelegate is part of ResponderChain and all work ok... But in this way all selectors of AppDelegate are _redirects_ to selectors in MainWinController. What i want to do is insert in ResponderChain of mainMenu my MainWinController so i don't need to put redirect selectors in AppDelegate – Shebuka Jul 17 '12 at 08:53