What is NSMenuWindowManagerWindow?

This question is mainly just a point of curiosity and education.

I'm working on one of my first macOS apps, and I see I can check NSApplication.shared.windows to get a list of all the application's windows. Most of the time, this list contains the windows I've programmed which are in memory. Sometimes, though, it also contains two instances of NSMenuWindowManagerWindow. This doesn't appear to be a documented type, and I'm inferring I'm seeing evidence of something NSApplication or the system is doing to help deliver or render some kind of standard application behaviour. I'm wondering whether any macOS gurus (or engineers) can shine some light on it.

Accepted Reply

Those windows are an implementation detail of menus. As a general rule, anything that appears on screen in our windowed environment is, itself, a window. That includes little bits of UI that you ordinarily wouldn’t think of, like typing suggestions, menu extras, context menus, and tooltips.

These can all appear in your application’s window list, alongside other framework-created panels like NSColorPanel and NSFontPanel, so use caution when acting on the array of all windows. If there’s a set of windows that you want to keep track of and iterate over, it’s often easier and more predictable to maintain your own list of those windows.

Replies

Those windows are an implementation detail of menus. As a general rule, anything that appears on screen in our windowed environment is, itself, a window. That includes little bits of UI that you ordinarily wouldn’t think of, like typing suggestions, menu extras, context menus, and tooltips.

These can all appear in your application’s window list, alongside other framework-created panels like NSColorPanel and NSFontPanel, so use caution when acting on the array of all windows. If there’s a set of windows that you want to keep track of and iterate over, it’s often easier and more predictable to maintain your own list of those windows.

Thank you – that's about what I was expecting. ^ ^