MenuBarModel question


I’m writing an app that can have multiple windows, so it seemed logical to me that my JUCEApplication inheritor should also inherit from MenuBarModel, since will own the menu that appears (on the mac at least) in the menu bar at the top, even when there are no windows present.

If I do that, however, the constructor for MenuBarModel will be called immediately, and will call getMenuForIndex() in my app class, and I won’t have had time to construct the ApplicationCommandManager member to add to the popup menu. So, this is clearly not the right way of organizing things.

How do others out there do this? If I put the MenuBarModel in my window class, then how do you handle the close of the last window? I’m sure there’s a simple solution, but I’m not seeing it. Any pointers?


MenuBarModels can change their contents, so it’s ok to create an empty one and add stuff to it later.