Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the main menu in Cocoa?

I have a cocoa app with two types windows each of which requires a different main menu to be displayed.

In my MainMenu.xib I have the default MainMenu. In Window1.xib I have Window1 and in Window2.xib I have Window2 and it's MainMenu.

When I have the first Window open I have the default Menu, when I open Window2 I get it's menu.

However, when I switch back to Window1 I still see Window2's menu. How do I make the menu that is displayed follow the key window?

like image 586
Roland Rabien Avatar asked Dec 03 '22 16:12

Roland Rabien


1 Answers

Generally, you shouldn't replace the entire main menu every time. It's more compliant with the Human Interface Guidelines to simply disable any menu items that don't apply to the current window. And if you really should have a completely different set of menus in the menu bar, maybe you should split that part of your application into a separate application.

like image 125
Peter Hosey Avatar answered Dec 21 '22 18:12

Peter Hosey