Main menu items disabled when last window closes

Hi all,

I’m building a multi-window application. When the user closes the last window, the application remains active and new windows may be opened at any time.

My problem is that whenever the last window has been closed the main menu items coming from the ApplicationCommandManager get disabled. I guess this has to do with the KeyPressMappingSet* in the command manager not being a KeyListener to any window anymore. Still, the Projucer pulls off what I want perfectly, and I do not see what I am doing different. Anyone care to help?

Stijn

1 Like

The menu commands will only be enabled when the command target is focused so if you are handling them in your window class or a subcomponent then the commands will be disabled when the windows are closed. The Projucer handles commands such as new project, open etc. in the application class (see here) so these will be enabled even when there are no open windows. Perhaps you need to do something similar?

Thanks for answering, ed95, I just solved the issue. The only ApplicationCommandTarget in my project is the Application, just like with the Projucer, so that wasn’t it (although a good guess). I was just handling ApplicationCommandInfo::setActive() incorrectly, so this turns out to be a stupid mistake on my side.