DesktopWindow.MenuBar

From Xojo Documentation

Revision as of 19:06, 23 July 2021 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Property (As DesktopMenuBar )
aDesktopWindow.MenuBar = newDesktopMenuBarValue
or
DesktopMenuBarValue = aDesktopWindow.MenuBar

New in 2021r3

Supported for all project types and targets.

The menubar that is associated with the window.

Notes

This is the DesktopMenuBar 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, DesktopApplication.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.

fa-info-circle-32.png
For MDI applications, the MDI window uses DesktopApplication.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 Self.MenuBar <> Nil Then
#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

DesktopMenuItem, DesktopApplication.MenuBar property, DesktopMenuBar class