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.
Inheritance
System.Object
MenuBar
Implements
System.IDisposable
System.ComponentModel.ISupportInitializeNotification
System.ComponentModel.ISupportInitialize
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Terminal.Gui.dll
public class MenuBar : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Constructors
|
Improve this Doc
View Source
Initializes a new instance of the
MenuBar.
Declaration
|
Improve this Doc
View Source
Initializes a new instance of the
MenuBar class with the specified set of toplevel menu items.
Declaration
public MenuBar(MenuBarItem[] menus)
Parameters
Type |
Name |
Description |
MenuBarItem[] |
menus |
Individual menu items; a null item will result in a separator being drawn. |
Properties
|
Improve this Doc
View Source
The specifier character for the hotkey to all menus.
Declaration
public static Rune HotKeySpecifier { get; }
Property Value
|
Improve this Doc
View Source
true if the menu is open; otherwise true.
Declaration
public bool IsMenuOpen { get; protected set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
The
Key used to activate the menu bar by keyboard.
Declaration
public Key Key { get; set; }
Property Value
|
Improve this Doc
View Source
Gets the view that was last focused before opening the menu.
Declaration
public View LastFocused { get; }
Property Value
|
Improve this Doc
View Source
Gets or sets the array of
MenuBarItems for the menu. Only set this after the
MenuBar is visible.
Declaration
public MenuBarItem[] Menus { get; set; }
Property Value
|
Improve this Doc
View Source
Sets or gets the shortcut delimiter separator. The default is "+".
Declaration
public static ustring ShortcutDelimiter { get; set; }
Property Value
|
Improve this Doc
View Source
Used for change the navigation key style.
Declaration
public bool UseKeysUpDownAsKeysLeftRight { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
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.
Declaration
public bool UseSubMenusSingleFrame { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Gets or sets a value indicating whether this
Responder and all its child controls are displayed.
Declaration
public override bool Visible { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Overrides
Methods
|
Improve this Doc
View Source
Closes the Menu programmatically if open and not canceled (as though F9 were pressed).
Declaration
public bool CloseMenu(bool ignoreUseSubMenusSingleFrame = false)
Parameters
Type |
Name |
Description |
System.Boolean |
ignoreUseSubMenusSingleFrame |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Method invoked when a mouse event is generated
Declaration
public override bool MouseEvent(MouseEvent me)
Parameters
Returns
Type |
Description |
System.Boolean |
true , if the event was handled, false otherwise. |
Overrides
|
Improve this Doc
View Source
Method invoked when a view gets focus.
Declaration
public override bool OnEnter(View view)
Parameters
Type |
Name |
Description |
View |
view |
The view that is losing focus. |
Returns
Type |
Description |
System.Boolean |
true , if the event was handled, false otherwise. |
Overrides
|
Improve this Doc
View Source
Method invoked when a key is pressed.
Declaration
public override bool OnKeyDown(KeyEvent keyEvent)
Parameters
Type |
Name |
Description |
KeyEvent |
keyEvent |
Contains the details about the key that produced the event. |
Returns
Type |
Description |
System.Boolean |
true if the event was handled |
Overrides
|
Improve this Doc
View Source
Method invoked when a key is released.
Declaration
public override bool OnKeyUp(KeyEvent keyEvent)
Parameters
Type |
Name |
Description |
KeyEvent |
keyEvent |
Contains the details about the key that produced the event. |
Returns
Type |
Description |
System.Boolean |
true if the event was handled |
Overrides
|
Improve this Doc
View Source
Method invoked when a view loses focus.
Declaration
public override bool OnLeave(View view)
Parameters
Type |
Name |
Description |
View |
view |
The view that is getting focus. |
Returns
Type |
Description |
System.Boolean |
true , if the event was handled, false otherwise. |
Overrides
|
Improve this Doc
View Source
Declaration
public virtual void OnMenuAllClosed()
|
Improve this Doc
View Source
Declaration
public virtual MenuClosingEventArgs OnMenuClosing(MenuBarItem currentMenu, bool reopen, bool isSubMenu)
Parameters
Type |
Name |
Description |
MenuBarItem |
currentMenu |
The current menu to be closed. |
System.Boolean |
reopen |
Whether the current menu will be reopen. |
System.Boolean |
isSubMenu |
Whether is a sub-menu or not. |
Returns
|
Improve this Doc
View Source
Virtual method that will invoke the
MenuOpened event if it's defined.
Declaration
public virtual void OnMenuOpened()
|
Improve this Doc
View Source
Virtual method that will invoke the
MenuOpening event if it's defined.
Declaration
public virtual MenuOpeningEventArgs OnMenuOpening(MenuBarItem currentMenu)
Parameters
Type |
Name |
Description |
MenuBarItem |
currentMenu |
The current menu to be replaced. |
Returns
|
Improve this Doc
View Source
Opens the Menu programatically, as though the F9 key were pressed.
Declaration
|
Improve this Doc
View Source
Positions the cursor in the right position based on the currently focused view in the chain.
Declaration
public override void PositionCursor()
Overrides
|
Improve this Doc
View Source
This method can be overwritten by views that
want to provide accelerator functionality
(Alt-key for example), but without
interefering with normal ProcessKey behavior.
Declaration
public override bool ProcessColdKey(KeyEvent kb)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides
|
Improve this Doc
View Source
This method can be overwritten by view that
want to provide accelerator functionality
(Alt-key for example).
Declaration
public override bool ProcessHotKey(KeyEvent kb)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides
|
Improve this Doc
View Source
If the view is focused, gives the view a
chance to process the keystroke.
Declaration
public override bool ProcessKey(KeyEvent kb)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides
|
Improve this Doc
View Source
Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.
Declaration
public override void Redraw(Rect bounds)
Parameters
Type |
Name |
Description |
Rect |
bounds |
The bounds (view-relative region) to redraw. |
Overrides
Events
|
Improve this Doc
View Source
Raised when all the menu is closed.
Declaration
public event Action MenuAllClosed
Event Type
Type |
Description |
System.Action |
|
|
Improve this Doc
View Source
Declaration
public event Action<MenuClosingEventArgs> MenuClosing
Event Type
|
Improve this Doc
View Source
Raised when a menu is opened.
Declaration
public event Action<MenuItem> MenuOpened
Event Type
Type |
Description |
System.Action<MenuItem> |
|
|
Improve this Doc
View Source
Raised as a menu is opening.
Declaration
public event Action<MenuOpeningEventArgs> MenuOpening
Event Type
Implements
System.IDisposable
System.ComponentModel.ISupportInitializeNotification
System.ComponentModel.ISupportInitialize