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 parent Toplevel View and uses the full width.

The MenuBar provides global hotkeys for the application. See HotKey.

See also: ContextMenu

Constructors

MenuBar()

Initializes a new instance of the MenuBar.

MenuBar(MenuBarItem[])

Initializes a new instance of the MenuBar class with the specified set of toplevel menu items.

Properties

HotKeySpecifier

The specifier character for the hotkey to all menus.

IsMenuOpen

true if the menu is open; otherwise true.

Key

The Key used to activate the menu bar by keyboard.

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.

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).

MouseEvent(MouseEvent)

Method invoked when a mouse event is generated

OnEnter(View)

Method invoked when a view gets focus.

OnKeyDown(KeyEvent)

Method invoked when a key is pressed.

OnKeyUp(KeyEvent)

Method invoked when a key is released.

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.

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.

ProcessColdKey(KeyEvent)

This method can be overwritten by views that want to provide accelerator functionality (Alt-key for example), but without interefering with normal ProcessKey behavior.

ProcessHotKey(KeyEvent)

This method can be overwritten by view that want to provide accelerator functionality (Alt-key for example).

ProcessKey(KeyEvent)

If the view is focused, gives the view a chance to process the keystroke.

Redraw(Rect)

Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.

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.