Table of Contents

Class MenuBar

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Provides a menu bar that spans the top of a Toplevel View with drop-down and cascading menus.

By default, any sub-sub-menus (sub-menus of the MenuItems added to MenuBarItems) are displayed in a cascading manner, where each sub-sub-menu pops out of the sub-menu frame (either to the right or left, depending on where the sub-menu is relative to the edge of the screen). By setting UseSubMenusSingleFrame to true, this behavior can be changed such that all sub-sub-menus are drawn within a single frame below the MenuBar.

public class MenuBar : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
MenuBar
Implements
Inherited Members

Remarks

The MenuBar appears on the first row of the Toplevel SuperView and uses the full width.

See also: ContextMenu

The MenuBar provides global hot keys for the application. See HotKey.

When the menu is created key bindings for each menu item and its sub-menu items are added for each menu item's hot key (both alone AND with AltMask) and shortcut, if defined.

If a key press matches any of the menu item's hot keys or shortcuts, the menu item's action is invoked or sub-menu opened.

* If the menu bar is not open * Any shortcut defined within the menu will be invoked * Only hot keys defined for the menu bar items will be invoked, and only if Alt is pressed too. * If the menu bar is open * Un-shifted hot keys defined for the menu bar items will be invoked, only if the menu they belong to is open (the menu bar item's text is visible). * Alt-shifted hot keys defined for the menu bar items will be invoked, only if the menu they belong to is open (the menu bar item's text is visible). * If there is a visible hot key that duplicates a shortcut (e.g. _File and Alt-F), the hot key wins.

Constructors

MenuBar()

Initializes a new instance of the MenuBar.

Properties

HotKeySpecifier

The specifier character for the hot keys.

IsMenuOpen

true if the menu is open; otherwise true.

Key

The Key used to activate or close the menu bar by keyboard. The default is F9 .

LastFocused

Gets the view that was last focused before opening the menu.

Menus

Gets or sets the array of MenuBarItems for the menu. Only set this after the MenuBar is visible.

MenusBorderStyle

The default LineStyle for Menus's border. The default is Single.

ShortcutDelimiter

Sets or gets the shortcut delimiter separator. The default is "+".

UseKeysUpDownAsKeysLeftRight

Used for change the navigation key style.

UseSubMenusSingleFrame

Gets or sets if the sub-menus must be displayed in a single or multiple frames.

By default any sub-sub-menus (sub-menus of the main MenuItems) are displayed in a cascading manner, where each sub-sub-menu pops out of the sub-menu frame (either to the right or left, depending on where the sub-menu is relative to the edge of the screen). By setting UseSubMenusSingleFrame to true, this behavior can be changed such that all sub-sub-menus are drawn within a single frame below the MenuBar.

Visible

Gets or sets a value indicating whether this Responder and all its child controls are displayed.

Methods

CloseMenu(bool)

Closes the Menu programmatically if open and not canceled (as though F9 were pressed).

OnDrawContent(Rectangle)

Draws the view's content, including Subviews.

OnInvokingKeyBindings(Key)

Low-level API called when a user presses a key; invokes any key bindings set on the view. This is called during NewKeyDownEvent(Key) after OnKeyDown(Key) has returned.

OnLeave(View)

Method invoked when a view loses focus.

OnMenuAllClosed()

Virtual method that will invoke the MenuAllClosed.

OnMenuClosing(MenuBarItem, bool, bool)

Virtual method that will invoke the MenuClosing.

OnMenuOpened()

Virtual method that will invoke the MenuOpened event if it's defined.

OnMenuOpening(MenuBarItem)

Virtual method that will invoke the MenuOpening event if it's defined.

OnMouseEvent(MouseEvent)

Called when a mouse event occurs within the view's Viewport.

OpenMenu()

Opens the Menu programatically, as though the F9 key were pressed.

PositionCursor()

Positions the cursor in the right position based on the currently focused view in the chain.

Events

MenuAllClosed

Raised when all the menu is closed.

MenuClosing

Raised when a menu is closing passing MenuClosingEventArgs.

MenuOpened

Raised when a menu is opened.

MenuOpening

Raised as a menu is opening.