MenuBar
Heading bar for child PopupMenus with local or native placement.
Add PopupMenus as direct MenuBar children. Each creates one heading; a nested submenu belongs to its PopupMenu, while ordinary Entity/Control children create no heading. Add commands to PopupMenu and handle its IdPressed rather than heading-bar events.
An index in 0…GetMenuCount()-1 is the position among direct PopupMenus, including hidden/disabled ones. Not a total child index or command ID. Reordering/removal changes indices. GetMenuPopup returns an existing child object; do not free it separately while owned by the bar. RemoveChild detaches without Free.
The default heading uses PopupMenu.Title, falling back to Name when Title is empty. SetMenuTitle supplies a separate bar caption without changing window Title/Name. Assigning the current source Title/Name restores automatic tracking. GetMenuTitle returns the original string rather than necessarily its displayed translation.
Current implementation limitation: MoveChild matches a cached menu record by original title. Identical titles can associate hidden/disabled flags and other data with the wrong PopupMenu. Use distinct original titles for dynamic reordering; if duplicates are required, create the bar directly in final order. Matching translations of distinct original strings are a separate case.
PreferGlobalMenu = true is a preference rather than a guarantee of native menus. Check IsNativeMenu. Set false for a predictable in-window bar. Native mode contributes zero local minimum size and uses platform appearance/handling; Flat and local theme do not style the OS menu. StartIndex orders MenuBar placement in the native bar rather than shifting local PopupMenu indices.
SetMenuHidden hides a heading without removing its menu. SetMenuDisabled blocks ordinary opening/shortcut handling through this bar; direct PopupMenu access and application handlers remain available. SetDisableShortcuts disables the local MenuBar shortcut route rather than every application shortcut or necessarily native-menu handling.
SwitchOnHover switches adjacent menus while one is already open; configure before opening. It does not open every menu on simple hover. Language/TextDirection control text shaping rather than application locale. When changing them dynamically, reapply headings through SetMenuTitle(i, GetMenuTitle(i)) to explicitly refresh text buffers.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
MenuBarConstructor
public MenuBar();Creates a bar: PreferGlobalMenu = true, SwitchOnHover = true, Flat = false, StartIndex = -1, empty Language, TextDirection.Auto. FocusMode = Accessibility; child PopupMenus supply headings.
Properties6
FlatProperty
public bool Flat { get; set; }Skip state-style drawing for local headings, default false. Text and theme sizing margins remain; does not change native-menu styling.
LanguageProperty
public string Language { get; set; }Heading shaping language; empty uses the control locale. Does not change original strings/application locale. Reapply headings through SetMenuTitle for immediate dynamic refresh.
PreferGlobalMenuProperty
public bool PreferGlobalMenu { get; set; }Prefer the native menu bar, default true. Requires NativeMenu support; check IsNativeMenu. false keeps the bar in the window. Not the actual-mode indicator.
StartIndexProperty
public int StartIndex { get; set; }MenuBar placement order in the native bar, default -1 appends. Does not reindex child PopupMenus or assign a command ID. Does not change local indices in in-window mode.
SwitchOnHoverProperty
public bool SwitchOnHover { get; set; }Switch between headings while a menu is open, default true. Configure before opening; ordinary hover over a closed bar does not itself open menus.
TextDirectionProperty
public Control.TextDirection TextDirection { get; set; }Shaping direction, default Auto; Inherited uses layout direction. Does not reverse original strings. Reapply headings to refresh shaping after a dynamic change.
Methods24
GetLanguagestring
public string GetLanguage();Heading shaping language; empty uses the control locale. Does not change original strings/application locale. Reapply headings through SetMenuTitle for immediate dynamic refresh.
stringShaping language, or empty.
GetMenuCountint
public int GetMenuCount();Number of direct child PopupMenus, including hidden/disabled; not the number of commands inside them.
intDirect PopupMenu count.
GetMenuPopupPopupMenu
public PopupMenu GetMenuPopup(int menu);Returns the shared child PopupMenu at the current index, null for missing/negative indices. Does not copy or open it.
| Name | Type | Default |
|---|---|---|
menu | int | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
PopupMenuShared child PopupMenu, or null.
GetMenuTitlestring
public string GetMenuTitle(int menu);Original heading caption. Not a stable ID and can differ from PopupMenu.Title or its displayed translation.
| Name | Type | Default |
|---|---|---|
menu | int | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
stringOriginal heading caption.
GetMenuTooltipstring
public string GetMenuTooltip(int menu);Stored heading tooltip rather than current tooltip visibility.
| Name | Type | Default |
|---|---|---|
menu | int | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
stringStored heading tooltip.
GetStartIndexint
public int GetStartIndex();MenuBar placement order in the native bar, default -1 appends. Does not reindex child PopupMenus or assign a command ID. Does not change local indices in in-window mode.
intPlacement order, or -1 for append.
GetTextDirectionControl.TextDirection
public Control.TextDirection GetTextDirection();Shaping direction, default Auto; Inherited uses layout direction. Does not reverse original strings. Reapply headings to refresh shaping after a dynamic change.
Control.TextDirectionCurrent Control.TextDirection.
IsFlatbool
public bool IsFlat();Skip state-style drawing for local headings, default false. Text and theme sizing margins remain; does not change native-menu styling.
boolLocal state-background skip flag.
IsMenuDisabledbool
public bool IsMenuDisabled(int menu);Heading disabled flag, separate from disabled states of its commands.
| Name | Type | Default |
|---|---|---|
menu | int | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
boolHeading disabled flag.
public bool IsMenuHidden(int menu);Heading hidden flag rather than PopupMenu window Visible state.
| Name | Type | Default |
|---|---|---|
menu | int | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
boolHeading hidden flag.
IsNativeMenubool
public bool IsNativeMenu();Returns whether native mode is supported and enabled for this bar. Disabled for the edited scene. Not equivalent to PreferGlobalMenu.
booltrue for supported, enabled native mode.
IsPreferGlobalMenubool
public bool IsPreferGlobalMenu();Prefer the native menu bar, default true. Requires NativeMenu support; check IsNativeMenu. false keeps the bar in the window. Not the actual-mode indicator.
boolNative-menu preference flag.
IsSwitchOnHoverbool
public bool IsSwitchOnHover();Switch between headings while a menu is open, default true. Configure before opening; ordinary hover over a closed bar does not itself open menus.
boolHover-switch flag for open menus.
SetDisableShortcutsvoid
public void SetDisableShortcuts(bool disabled);Disables local MenuBar shortcut handling. Does not block direct PopupMenu actions or globally disable input/native menus. This SDK supplies no getter.
| Name | Type | Default |
|---|---|---|
disabled | bool | — |
disabledDisables local MenuBar shortcut handling. Does not block direct PopupMenu actions or globally disable input/native menus. This SDK supplies no getter.
SetFlatvoid
public void SetFlat(bool enabled);Skip state-style drawing for local headings, default false. Text and theme sizing margins remain; does not change native-menu styling.
| Name | Type | Default |
|---|---|---|
enabled | bool | — |
enabledSkip state-style drawing for local headings, default false. Text and theme sizing margins remain; does not change native-menu styling.
SetLanguagevoid
public void SetLanguage(string language);Heading shaping language; empty uses the control locale. Does not change original strings/application locale. Reapply headings through SetMenuTitle for immediate dynamic refresh.
| Name | Type | Default |
|---|---|---|
language | string | — |
languageHeading shaping language; empty uses the control locale. Does not change original strings/application locale. Reapply headings through SetMenuTitle for immediate dynamic refresh.
SetMenuDisabledvoid
public void SetMenuDisabled(int menu, bool disabled);Disables the heading for ordinary input and the local shortcut route. Record/index/child PopupMenu remain. Does not block calling an application command handler from code.
| Name | Type | Default |
|---|---|---|
menu | int | — |
disabled | bool | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
disabledDisables the heading for ordinary input and the local shortcut route. Record/index/child PopupMenu remain. Does not block calling an application command handler from code.
public void SetMenuHidden(int menu, bool hidden);Hides the heading without removing PopupMenu or changing GetMenuCount. Does not prevent direct access to the menu object.
| Name | Type | Default |
|---|---|---|
menu | int | — |
hidden | bool | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
hiddenHides the heading without removing PopupMenu or changing GetMenuCount. Does not prevent direct access to the menu object.
SetMenuTitlevoid
public void SetMenuTitle(int menu, string title);Sets the heading caption without changing PopupMenu.Title/Name. Matching current source Title/Name restores automatic tracking. Reassignment refreshes shaping.
| Name | Type | Default |
|---|---|---|
menu | int | — |
title | string | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
titleSets the heading caption without changing PopupMenu.Title/Name. Matching current source Title/Name restores automatic tracking. Reassignment refreshes shaping.
SetMenuTooltipvoid
public void SetMenuTooltip(int menu, string tooltip);Sets a separate bar-heading tooltip. Does not change tooltips of commands inside PopupMenu.
| Name | Type | Default |
|---|---|---|
menu | int | — |
tooltip | string | — |
menuIndex 0…GetMenuCount()-1; GetMenuPopup returns null for a missing index.
tooltipSets a separate bar-heading tooltip. Does not change tooltips of commands inside PopupMenu.
SetPreferGlobalMenuvoid
public void SetPreferGlobalMenu(bool enabled);Prefer the native menu bar, default true. Requires NativeMenu support; check IsNativeMenu. false keeps the bar in the window. Not the actual-mode indicator.
| Name | Type | Default |
|---|---|---|
enabled | bool | — |
enabledPrefer the native menu bar, default true. Requires NativeMenu support; check IsNativeMenu. false keeps the bar in the window. Not the actual-mode indicator.
SetStartIndexvoid
public void SetStartIndex(int enabled);MenuBar placement order in the native bar, default -1 appends. Does not reindex child PopupMenus or assign a command ID. Does not change local indices in in-window mode.
| Name | Type | Default |
|---|---|---|
enabled | int | — |
enabledInteger native placement order, -1 for append; the SDK name enabled does not make it boolean.
SetSwitchOnHovervoid
public void SetSwitchOnHover(bool enable);Switch between headings while a menu is open, default true. Configure before opening; ordinary hover over a closed bar does not itself open menus.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableSwitch between headings while a menu is open, default true. Configure before opening; ordinary hover over a closed bar does not itself open menus.
SetTextDirectionvoid
public void SetTextDirection(Control.TextDirection direction);Shaping direction, default Auto; Inherited uses layout direction. Does not reverse original strings. Reapply headings to refresh shaping after a dynamic change.
| Name | Type | Default |
|---|---|---|
direction | Control.TextDirection | — |
directionShaping direction, default Auto; Inherited uses layout direction. Does not reverse original strings. Reapply headings to refresh shaping after a dynamic change.
Theme properties
These are Theme resource keys, not C# properties. Use the matching Control GetTheme…() and AddTheme…Override() methods for each value type.
| Key and type | Description |
|---|---|
font_colorColor | Default text Color(0.875, 0.875, 0.875, 1) |
font_disabled_colorColor | Text Color(0.875, 0.875, 0.875, 0.5) |
font_focus_colorColor | Text Color(0.95, 0.95, 0.95, 1) |
font_hover_colorColor | Text Color(0.95, 0.95, 0.95, 1) |
font_hover_pressed_colorColor | Text Color(1, 1, 1, 1) |
font_outline_colorColor | The tint of text outline of the menu item. Default:Color(0, 0, 0, 1) |
font_pressed_colorColor | Text Color(1, 1, 1, 1) |
h_separationint | The horizontal space between menu items. Default:4 |
outline_sizeint | The size of the text outline.
Note: If using a font with 0 |
fontFont |
|
font_sizeint | Font size of the menu item's text. |
disabledStyleBox |
|
disabled_mirroredStyleBox |
|
hoverStyleBox |
|
hover_mirroredStyleBox |
|
hover_pressedStyleBox |
|
hover_pressed_mirroredStyleBox |
|
normalStyleBox | Default |
normal_mirroredStyleBox | Default |
pressedStyleBox |
|
pressed_mirroredStyleBox |
|