Menu assigned to window not showing on Mac when the window is opened/selected

Hi I’ve developed an app on windows xojo and wanting to compile for mac too. So far not too bad, all the functionality is there, just some GUI / font stuff to solve.

My biggest problem is that I don’t understand how how get a different menu bar to appear when in a second window when it opens / has focus. On windows, the menu bar obviously appears within the window its-self, on mac you have one menu bar for the whole app. I’ve seen a similar thread with the same issue from a few year ago, but there was never an answer. so app is like:

App MenuBar = non
Window 1 = non
Window 2 (main interface) = MenuBar 1 (frame = document, behaviour set to default)
Window 3 (edit interface) = MenuBar 2 (frame = floating window, behaviour currently set to parent window)
And then various other minor windows with no Menubars attached to them.

When the user gets to windows 2, menu bar 1 shows as it should. When the user then opens window 3, it remains on MenuBar 1, selecting the window does nothing.
Window 3 is a non resalable window over the top of window 2. The user can still access window 2 while window 3 is open - this is the functionality I want. I expected the menu bar to change to the appropriate one when the user selects/set focus on the window they are on. But I am not that knowledgeable on MacOS.

It worth noting, that I think when the user selects a window that doesn’t have a menu bar attached to it the menubar goes blank in Mac… which is expected I guess. But this only happens after they have clicked on the window (or I think even when they have selected the main window and then went back to the other window), not when it’s opened. But that doesn’t make sense as to why it wouldn’t show the other MenuBar2.

I’m having to compile it on windows and then reboot on to mac OS to test it my computer will only go up to EL captain. Which is a bit of a pain, so hoping there’s a straight forward answer. I have ended up with fair amounts of open event codes on the windows, but I don’t know if or why that would interfere with this problem.

First of all, make sure you have a default menubar assigned to the app itself for situations when there are no windows present. This will also cover situations where a window does not have a menubar assigned.

Now, on macOS the type of window and its parent matters… so make sure all of your windows are Document windows.

Thanks for your help Greg.
So now the menu changes to the correct one on window 2, but only after either:

  1. I click on any of the buttons on the window (window 2)
  2. Return to back to window 1, then back to window 2.

Is that normal behaviour? I would have thought the menu should change as soon as the window opens or clicked / has focus? Seem a little awkward. I would really like the menu to change appear easily as there are some functions/keyboard shortcuts assigned to the menu bar that are not accessible just on the window 2 GUI.

The fact that there was similar behaviour with the original settings -when it made the menu bar blank with the other windows (ie windows with no menu bar attached to them) makes me think that this is a problem not necessarily associated just with Window 2?

In Window2.opening try Self.Focus = Nil

Can’t seem to get it working, I seemed to have tried everything with regards to the open event.

Is there any particular reason why it switches to the correct menu bar after clicking on any button control (sorry I meant to say the new window that opens). Why does it trigger it to change when I click a button?
it also seems to switch to correct menu bar, if i move to a different app and then back again.

Tempted to try and change the menu bar for the main window behind it to the new menu bar on the window activate event… but seems like a drastic solution.