Menubar and Floating Window

I have a tool window with a menubar that works fine on Windows but on Mac the menubar does not show (remains main window menubar) unless I change the window to a different type such as document window but this is not suitable. Any ideas?

On Mac, the menu is on top of the screen, not under the window bar.

From what I see here, the menu changes with the window, as expected.

Yes I know but it does not show for floating windows apparently.

Oh Floating window. That is what you meant by “Tool window”…

Here is my solution, events of the floating window :

[code]Sub Open() Handles Open
Window1.MenuBar = Mainmenubar1

End Sub

[code]Sub Close() Handles Close
Window1.menubar = MainMenuBar

End Sub

Lol. That’s exactly what I’ve been trying. Great minds. :slight_smile: However the EnableMenuItems event of the floating window doesn’t seem to trigger and all the menubar menus and items are all disabled.

You probably still need to have menu handlers on your floating window for the menuitems to be enabled.

Yes I have these and as I say it all works fine on Windows. If I swap menu bars around with the main window while the floating window is active the EnableMenuItems event of the main window fires instead of the EnableMenuItems event of the floating window. So I’m trying to figure out how to use the same code from the EnableMenuItems event of the floating window in the main window’s EnableMenuItems event because I can’t reference the menu item objects in the same way because they belong to different windows and have different associated menu handlers. And even if I can enable/disable menus as I need I’m not sure it’s possible to access the menu handler events from the floating window.

You will have to experiment placing a menu handler on the main window, or on the floating one, and see which one enables.

If need be, you could also centralize everything on app for easy access.

I managed to create a MenuHandler event in the main window that has the same name as the MenuHandler event of the floating window and then in the EnableMenuItems event of the main window I check to see what menubar is being used and if it’s the floating window one then I have to manually hard code a menu item lookup routine to grab the appropriate menu (by name) in order to modify its child menu caption or enable/disable it as required. And if enabled and you select it, the main window duplicate MenuHandler (of the same name) handles the event as it should.

So it seems it’s possible but a hell of a lot of code to do this what with adding all the duplicate menu handlers in the main window etc. I’m not adverse to hard work, that’s not the issue, it just seems a real illogical hack and a complex mess of coding to solve a problem. I’d prefer a cleaner solution if at all possible.

Can you think of any other way that is more logical…and simple?

And what do you mean exactly by centralizing everything on the app?

You could have all the handlers in app.

I don’t understand why you have to duplicate your handlers BTW, and why it should be much more complex.

I have the handlers for the floating window in the floating window and this works fine in Windows because the menubar is part of the window itself, but I would need to either duplicate them in the main window (so swapping over the menubar works) or as you say put them in the App but I’ve not assigned a menubar to the App class before and am not sure how it works or what else it might break.

Hi again. I’ve now managed to swap menu bars over and it’s working but there’s one issue which is important for my app: the accessibility inspector and Cocoa dictation isn’t registering the change of menu bars (and updating its accessible items list with their values) until the app loses focus to another app or the desktop and then regains focus.

Does anyone know how to force Cocoa to update in Xojo or by calling NSAccessibilityValueChangedNotification through a declare?