Xojo Menus with 2 Windows

I have an app that has a MainWindow that uses the default MainMenuBar. Works fine on its own.
I have a status window (tried various types (Document/Modeless, etc.) but have issues with each. (I don’t want the StatusWindow to be Modal, BTW)
If it’s a Document, Modeless Dialog or Metal, it works the same on both Mac and Windows, but on Mac, when the StatusWindow has the focus, the menubar is disabled (items are there, but inactive/greyed out).
If I use Floating Window or Global Floating Window, the menu works again, but in Windows there are no Control Icons (Minimize/Maximize).

I guess since Floating doesn’t have the needed controls, how would I go about making the Menu active for a Document or Modeless Dialog Window, when it has the focus, the way a Floating window does?

I’ll assume the menu items themselves are set to have “AutoEnable” on
Thats the default

What that means is that IF you create a menu handler for that menu item then the menu item should automatically enable just by making that window active

If every member of a menu is disabled then the top item in the menu bar will also show as disabled

Ok, so the menus are set to AutoEnable and the MenuHandlers are in the MainWindow. With some Window types for the StatusWindow, the menu items stay enabled, with others, they “auto disable” the way you describe.
If I turn off “AutoEnable”, they become disabled all the time.
I’d like them Enabled all the time, but I’d also like to know why some types of Windows disable the Menus and some don’t.
Also, if the MainMenu is “app-wide”, how come it’s handlers can’t be part of App instead of MainWindow?

Those then should only enable when main window has focus

really depends on the controls on status window as well
some, like text areas, will make certain cut copy paste ones enable

That I would expect

Some window type cannot have a menu bar

You could put every menu handler in app but thats restrictive because you no longer have access to the window controls and their data
So put the ones that need access to the window and its data on the window

I have this vague recollection of there being a a bug report about switching menu bars
Let me see if I can find it

I tend to NOT switch menu bars at all and just enable disable items

Thanks, Norm.
So what’s the solution then?
Do I have to add an EnableMenuItems event on both windows and enable all the menus manually?
(Why is there no “enabled” setting in the IDE for menuitems??)
Do I have to manually enable all the menu items in the “Open” event of the App or Window?
Do I have to add copies of the handlers in each window?

The answer is “it depends” - see below

AutoEnable is “usually” enough

However, IF you find that that menus are not enabling / disabling as you switch back and forth between windows you could, in the Window activate event, call EnableMenuItems which will then get the enable menu items events for the controls Etc to run (I forget the name they gave it in API 2)

Mostly because they need to be kind of context sensitive (ie/ specialized per window)
Hence the Autoenable property
They enable when there is a menu handler and disable when there isnt one
For instance Edit > Copy usually needs to be sensitive on a per control basis as in the app it makes no sense to try & copy a controls data where you have no access to it
And Edit > Copy needs to be aware of whether its a text area or listbox or some other control to do the right thing

On the other hand App > New Project (like in the IDE) doesnt need to be implemented anywhere else than in the app because other projects being open is irrelevant

in the enable menu items event is a much better place

well if its only in one window currently but you want it to apply to all windows then you might - often this is one that might apply better in the App instance
Unless it needs some info from the window then you do need to put it in that window to it can easily access that windows controls & data

Newly added windows do not have MenuBar attached by default.

Do you set one to that Window (in its Properties) ?

Calling EnableMenuItems on the Debug Window does not enable them. (Which makes sense because those menu items are likely part of MainWindow). I expect if I add handlers inside the DebugWindow then all the menuitems would be active, but that’s pretty clunky.
Still haven’t figured out a simple solution yet.

Basically, I want 1 menu bar, same for all windows, active all the time that the MainWindow is open, (but even when MainWindow is not the active/focused window)

the menu handlers in a non-focused window wont be used because it doesnt have focus

any menu item that needs to be “active” in more than one window can be moved to the App and it will then be used by any / all windows

That’s it.

I didn’t realize the Menu Handlers COULD be part of App. (It didn’t allow me to drag them there, but cut/paste did work - slight IDE bug?)

Cheers, Norm!

or just add one :stuck_out_tongue:
I tend to right click on everything in just about every app - that would let you see what items y oucan add to App

1 Like

This is actually not true on Mac OS (per Apple’s own Human Interface Guidelines).