Window.MenuBar
From Xojo Documentation
or
MenuBarValue = aWindow.MenuBar
Supported for all project types and targets.
The menubar that is associated with the window.
Notes
This is the MenuBar to use with the window. Typically this is the MenuBar that was added to the project by default, but it can be any MenuBar in your project.
When the window is active, this MenuBar is displayed.
MacOS Info
On macOS, if no MenuBar is assigned to the window, Application.MenuBar is used. To hide the MenuBar, set the MenuBar property to None (in the Inspector) or Nil (in code) for both the window and the Application.
Microsoft Windows and Linux
On Microsoft Windows and Linux, a window can have a MenuBar just below its title bar. The MenuBar assigned to the window is used as the window MenuBar. If the window does not have a MenuBar specified (i.e. it is set to None in the Inspector or Nil in code), then the window will not display a MenuBar.
For MDI applications, the MDI window uses Application.MenuBar as its MenuBar. Individual document windows cannot have a MenuBar (a Windows limitation). However, floating windows can have a MenuBar and these windows use the MenuBar specified in the window. |
Example
This code in a PushButton toggles the MenuBar on and off:
#If TargetMacOS Then
App.MenuBar = Nil
#Endif
Self.MenuBar = Nil
Else
#If TargetMacOS Then
App.MenuBar = MainMenuBar
#Endif
Self.MenuBar = MainMenuBar
End If
See Also
MenuItem, Application.MenuBar property, MenuBar class