Search Results for

    Show / Hide Table of Contents

    Class MenuBar

    Provides a menu bar with drop-down and cascading menus.
    Inheritance
    System.Object
    Responder
    View
    MenuBar
    Implements
    System.IDisposable
    System.ComponentModel.ISupportInitializeNotification
    System.ComponentModel.ISupportInitialize
    Remarks

    The MenuBar appears on the first row of the terminal.

    The MenuBar provides global hotkeys for the application.

    Inherited Members
    View.GetMinWidthHeight(Size)
    View.SetMinWidthHeight()
    View.UpdateTextFormatterText()
    View.ProcessResizeView()
    View.SetNeedsDisplay()
    View.ClearLayoutNeeded()
    View.SetNeedsDisplay(Rect)
    View.SetChildNeedsDisplay()
    View.Add(View)
    View.Add(View[])
    View.RemoveAll()
    View.Remove(View)
    View.BringSubviewToFront(View)
    View.SendSubviewToBack(View)
    View.SendSubviewBackwards(View)
    View.BringSubviewForward(View)
    View.Clear()
    View.Clear(Rect)
    View.ScreenToView(Int32, Int32)
    View.ClipToBounds()
    View.SetClip(Rect)
    View.DrawFrame(Rect, Int32, Boolean)
    View.DrawHotString(ustring, Attribute, Attribute)
    View.DrawHotString(ustring, Boolean, ColorScheme)
    View.Move(Int32, Int32, Boolean)
    View.OnAdded(View)
    View.OnRemoved(View)
    View.AddRune(Int32, Int32, Rune)
    View.ClearNeedsDisplay()
    View.OnDrawContent(Rect)
    View.OnDrawContentComplete(Rect)
    View.SetFocus()
    View.InvokeKeybindings(KeyEvent)
    View.AddKeyBinding(Key, Command)
    View.ReplaceKeyBinding(Key, Key)
    View.ContainsKeyBinding(Key)
    View.ClearKeybindings()
    View.ClearKeybinding(Key)
    View.ClearKeybinding(Command)
    View.AddCommand(Command, Func<Nullable<Boolean>>)
    View.GetSupportedCommands()
    View.GetKeyFromCommand(Command)
    View.EnsureFocus()
    View.FocusFirst()
    View.FocusLast()
    View.FocusPrev()
    View.FocusNext()
    View.LayoutSubviews()
    View.ToString()
    View.GetAutoSize()
    View.GetHotKeySpecifierLength(Boolean)
    View.GetTextFormatterBoundsSize()
    View.GetBoundsTextFormatterSize()
    View.OnMouseEnter(MouseEvent)
    View.OnMouseLeave(MouseEvent)
    View.OnMouseEvent(MouseEvent)
    View.OnMouseClick(View.MouseEventArgs)
    View.OnCanFocusChanged()
    View.OnEnabledChanged()
    View.OnVisibleChanged()
    View.Dispose(Boolean)
    View.BeginInit()
    View.EndInit()
    View.SetWidth(Int32, Int32)
    View.SetHeight(Int32, Int32)
    View.GetCurrentWidth(Int32)
    View.GetCurrentHeight(Int32)
    View.GetNormalColor()
    View.GetTopSuperView()
    View.HotKey
    View.Shortcut
    View.ShortcutTag
    View.ShortcutAction
    View.Data
    View.Driver
    View.Subviews
    View.TabIndexes
    View.TabIndex
    View.TabStop
    View.CanFocus
    View.Id
    View.IsCurrentTop
    View.WantMousePositionReports
    View.WantContinuousButtonPressed
    View.Frame
    View.LayoutStyle
    View.Bounds
    View.X
    View.Y
    View.Width
    View.Height
    View.ForceValidatePosDim
    View.TextFormatter
    View.SuperView
    View.HasFocus
    View.Focused
    View.MostFocused
    View.ColorScheme
    View.Text
    View.AutoSize
    View.PreserveTrailingSpaces
    View.TextAlignment
    View.VerticalTextAlignment
    View.TextDirection
    View.IsInitialized
    View.IsAdded
    View.Enabled
    View.Visible
    View.Border
    View.Added
    View.Removed
    View.Enter
    View.Leave
    View.MouseEnter
    View.MouseLeave
    View.MouseClick
    View.CanFocusChanged
    View.EnabledChanged
    View.VisibleChanged
    View.HotKeyChanged
    View.DrawContent
    View.DrawContentComplete
    View.KeyPress
    View.KeyDown
    View.KeyUp
    View.LayoutStarted
    View.LayoutComplete
    View.Initialized
    Responder.Dispose()
    Namespace: Terminal.Gui
    Assembly: Terminal.Gui.dll
    Syntax
    public class MenuBar : View

    Constructors

    MenuBar()

    Initializes a new instance of the MenuBar.
    Declaration
    public MenuBar()

    MenuBar(MenuBarItem[])

    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

    HotKeySpecifier

    The specifier character for the hotkey to all menus.
    Declaration
    public static Rune HotKeySpecifier { get; }
    Property Value
    Type Description
    System.Rune

    IsMenuOpen

    True if the menu is open; otherwise false.
    Declaration
    public bool IsMenuOpen { get; protected set; }
    Property Value
    Type Description
    System.Boolean

    LastFocused

    Get the lasted focused view before open the menu.
    Declaration
    public View LastFocused { get; }
    Property Value
    Type Description
    View

    Menus

    Gets or sets the array of MenuBarItems for the menu. Only set this when the MenuBar is visible.
    Declaration
    public MenuBarItem[] Menus { get; set; }
    Property Value
    Type Description
    MenuBarItem[] The menu array.

    ShortcutDelimiter

    Used for change the shortcut delimiter separator.
    Declaration
    public static ustring ShortcutDelimiter { get; set; }
    Property Value
    Type Description
    NStack.ustring

    UseKeysUpDownAsKeysLeftRight

    Used for change the navigation key style.
    Declaration
    public bool UseKeysUpDownAsKeysLeftRight { get; set; }
    Property Value
    Type Description
    System.Boolean

    UseSubMenusSingleFrame

    Gets or sets if the sub-menus must be displayed in a single or multiple frames.
    Declaration
    public bool UseSubMenusSingleFrame { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    CloseMenu(Boolean)

    Closes the current Menu programatically, if open and not canceled.
    Declaration
    public bool CloseMenu(bool ignoreUseSubMenusSingleFrame = false)
    Parameters
    Type Name Description
    System.Boolean ignoreUseSubMenusSingleFrame
    Returns
    Type Description
    System.Boolean

    MouseEvent(MouseEvent)

    Method invoked when a mouse event is generated
    Declaration
    public override bool MouseEvent(MouseEvent me)
    Parameters
    Type Name Description
    MouseEvent me
    Returns
    Type Description
    System.Boolean true, if the event was handled, false otherwise.
    Overrides
    Responder.MouseEvent(MouseEvent)

    OnEnter(View)

    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
    View.OnEnter(View)

    OnKeyDown(KeyEvent)

    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
    View.OnKeyDown(KeyEvent)

    OnKeyUp(KeyEvent)

    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
    View.OnKeyUp(KeyEvent)

    OnLeave(View)

    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
    View.OnLeave(View)

    OnMenuAllClosed()

    Virtual method that will invoke the MenuAllClosed
    Declaration
    public virtual void OnMenuAllClosed()

    OnMenuClosing(MenuBarItem, Boolean, Boolean)

    Virtual method that will invoke the MenuClosing
    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
    Type Description
    MenuClosingEventArgs

    OnMenuOpened()

    Virtual method that will invoke the MenuOpened event if it's defined.
    Declaration
    public virtual void OnMenuOpened()

    OnMenuOpening(MenuBarItem)

    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
    Type Description
    MenuOpeningEventArgs Returns the MenuOpeningEventArgs

    OpenMenu()

    Opens the current Menu programatically.
    Declaration
    public void OpenMenu()

    PositionCursor()

    Positions the cursor in the right position based on the currently focused view in the chain.
    Declaration
    public override void PositionCursor()
    Overrides
    View.PositionCursor()

    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.
    Declaration
    public override bool ProcessColdKey(KeyEvent kb)
    Parameters
    Type Name Description
    KeyEvent kb
    Returns
    Type Description
    System.Boolean
    Overrides
    View.ProcessColdKey(KeyEvent)

    ProcessHotKey(KeyEvent)

    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
    Type Name Description
    KeyEvent kb
    Returns
    Type Description
    System.Boolean
    Overrides
    View.ProcessHotKey(KeyEvent)

    ProcessKey(KeyEvent)

    If the view is focused, gives the view a chance to process the keystroke.
    Declaration
    public override bool ProcessKey(KeyEvent kb)
    Parameters
    Type Name Description
    KeyEvent kb
    Returns
    Type Description
    System.Boolean
    Overrides
    View.ProcessKey(KeyEvent)

    Redraw(Rect)

    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
    View.Redraw(Rect)

    Events

    MenuAllClosed

    Raised when all the menu are closed.
    Declaration
    public event Action MenuAllClosed
    Event Type
    Type Description
    System.Action

    MenuClosing

    Raised when a menu is closing passing MenuClosingEventArgs.
    Declaration
    public event Action<MenuClosingEventArgs> MenuClosing
    Event Type
    Type Description
    System.Action<MenuClosingEventArgs>

    MenuOpened

    Raised when a menu is opened.
    Declaration
    public event Action<MenuItem> MenuOpened
    Event Type
    Type Description
    System.Action<MenuItem>

    MenuOpening

    Raised as a menu is opening.
    Declaration
    public event Action<MenuOpeningEventArgs> MenuOpening
    Event Type
    Type Description
    System.Action<MenuOpeningEventArgs>

    Implements

    System.IDisposable
    System.ComponentModel.ISupportInitializeNotification
    System.ComponentModel.ISupportInitialize
    In This Article
    Back to top Generated by DocFX