Using the Window Menu

Most Cocoa applications include the Window menu, which displays the titles of various of the application’s windows. When you change a window’s title, this change is automatically reflected in the Window menu. This menu automatically lists windows that have a title bar and are resizable and that can become the main window (as described in “Window Layering and Types of Windows”). Typically you can rely on the automatic updating provided by Cocoa. In rare circumstances, however, you might want to modify the default behavior.

You can exclude a window that would otherwise be listed in the Window menu by sending it a setExcludedFromWindowsMenu:YES message. Since they cannot become main, NSPanel objects are excluded from the Windows menu. Instances of subclasses of NSPanel can be included in the menu by returning NO from its isExcludedFromWindowsMenu method and YES from its canBecomeMainWindow method. If you change a window’s configuration such that it should be added to or removed from the Window menu, you can update the Window menu by sending the shared application instance addWindowsItem:title:filename: or removeWindowsItem:.