Im trying to convert my app (a music composition system called Grace) to use setMacMainMenu(), and am not having much luck. My app has two main types of windows: a singleton ConsoleWindow (built on juce::TextEditor) and any number of CodeEditorWindows (built on juce::CodeEditorCOmponent). In the current working app each window has its own command manager and menubar model. the menu items respond really well to the state of the window (eg region selection and keyboard commands) . Ive tried two different ways to convert this working version to one in which windows dont have menubars but use the MacMainMenu instead. My first attempt is to keep everything the same, except I replace my setMenuBar(this) in the window constructors with a dynamic “menu bar install” using activeWindowStatusChanged() , eg:
I do the same for the CodeEditorWindow. It actually appears to work, in the sense that when different windows are selected the menu bar changes and installs the differnt menus. However, the menus dont respond they way they do if the meny is in the window. For example if i lick on the Console window to make it active it does install its mens but if I then select a region in the console window (say) and then click on its Edit menu in the MacMainMenu, then the various copy/paste item in the Edit menu have not adjusted to the fact that there is a region selected in the console. However, if I revernt that menubar back to the constructor way and i dont use the MacMainMenu or activeWindowStatusChanged then the menbar works perfectly.
The first qustion I have is his, how would I “wake up:” the MacMainMenu after a region has been selected in the windows?
THe second question is larger: is this the right way to convert my app? Ive also tried using one app-wide applicationCommandManager and app-wide menubarmodel whose perform() and getCommandInfo() methods use getActiveWIndow() to make the items responsive to the currenly selected window. It also seems to work except that – just like the first method – the mac menubar does not notice when a region has been selected in the active window. There may be other things its not noticing, Im stuck on the edit item for now until I know how to fix it.
sorry for the length, and thanks for any help!
Assoc. Prof. Composition/Theory
Chair, Composition/Theory Division
School of Music
University of Illinois at Urbana-Champaign
Fax: 1 217 244 7767
Vox: 1 217 244 2684