Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding static items to "Windows" menu in Cocoa application

I have a application with 2 windows (think like Twitter Timeline and mentions). For now I have been having the menus "Timeline ⌘1" and "Mentions ⌘2" in the "File" menu but this is kind of wrong. So I moved them to the "Windows" menu just by drag and drop.

When I open the application everything is nice, I can see both menu items unter the "Windows" menu. But then when I close for example the Mentions window the menu Item "Mentions ⌘2" disappears and I am not able to open this window anymore.

I have had a look at other applications and most of them have their Menu items to show the windows in the "Windows" menu and they don't disappear either after closing the windows. I am aware of the fact that Cocoa does soma magic with the "Window" menu item and it is quite ok in doing so (because I open some other windows which need to appear and disappear from there), but how can I make those two items kind of static so they don't disappear?

like image 915
Jeena Avatar asked Dec 04 '22 13:12

Jeena


1 Answers

I finally found an answer, in order for them to not be handled by the Windows menu you need to call

[timelineViewWindow setExcludedFromWindowsMenu:YES];
[mentionsViewWindow setExcludedFromWindowsMenu:YES];

and after that add the Menu items to the Windows menu and they will not disappear anymore.

like image 188
Jeena Avatar answered Dec 20 '22 23:12

Jeena