Show / Hide Table of Contents

    Class MenuBar

    The MenuBar provides a menu for Terminal.Gui applications.
    Inheritance
    System.Object
    Responder
    View
    MenuBar
    Implements
    System.IDisposable
    System.ComponentModel.ISupportInitializeNotification
    System.ComponentModel.ISupportInitialize
    Inherited Members
    View.Added
    View.Removed
    View.Enter
    View.Leave
    View.MouseEnter
    View.MouseLeave
    View.MouseClick
    View.HotKey
    View.HotKeySpecifier
    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.SuperView
    View.SetNeedsDisplay()
    View.SetNeedsDisplay(Rect)
    View.ChildNeedsDisplay()
    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)
    View.HasFocus
    View.OnAdded(View)
    View.OnRemoved(View)
    View.OnEnter(View)
    View.Focused
    View.MostFocused
    View.ColorScheme
    View.AddRune(Int32, Int32, Rune)
    View.ClearNeedsDisplay()
    View.DrawContent
    View.OnDrawContent(Rect)
    View.SetFocus()
    View.KeyPress
    View.ProcessColdKey(KeyEvent)
    View.KeyDown
    View.KeyUp
    View.EnsureFocus()
    View.FocusFirst()
    View.FocusLast()
    View.FocusPrev()
    View.FocusNext()
    View.LayoutStarted
    View.LayoutComplete
    View.Initialized
    View.LayoutSubviews()
    View.Text
    View.TextAlignment
    View.IsInitialized
    View.ToString()
    View.OnMouseEnter(MouseEvent)
    View.OnMouseLeave(MouseEvent)
    View.OnMouseEvent(MouseEvent)
    View.OnMouseClick(View.MouseEventArgs)
    View.Dispose(Boolean)
    View.BeginInit()
    View.EndInit()
    View.Visible
    Responder.Dispose()
    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)
    Namespace: Terminal.Gui
    Assembly: Terminal.Gui.dll
    Syntax
    public class MenuBar : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
    Remarks

    The MenuBar appears on the first row of the terminal.

    The MenuBar provides global hotkeys for the application.

    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

    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 vislble.
    Declaration
    public MenuBarItem[] Menus { get; set; }
    Property Value
    Type Description
    MenuBarItem[] The menu array.

    UseKeysUpDownAsKeysLeftRight

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

    Methods

    CloseMenu()

    Closes the current Menu programatically, if open.
    Declaration
    public void CloseMenu()

    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)

    OnKeyDown(KeyEvent)

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

    OnKeyUp(KeyEvent)

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

    OnMenuClosing()

    Virtual method that will invoke the MenuClosing
    Declaration
    public virtual void OnMenuClosing()

    OnMenuOpening()

    Virtual method that will invoke the MenuOpening
    Declaration
    public virtual void OnMenuOpening()

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

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

    Before keys are sent to the subview on the current view, all the views are processed and the key is passed to the widgets to allow some of them to process the keystroke as a hot-key.

    For example, if you implement a button that has a hotkey ok "o", you would catch the combination Alt-o here. If the event is caught, you must return true to stop the keystroke from being dispatched to other views.

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

    Views can override this method if they are interested in processing the given keystroke. If they consume the keystroke, they must return true to stop the keystroke from being processed by other widgets or consumed by the widget engine. If they return false, the keystroke will be passed using the ProcessColdKey method to other views to process.

    The View implementation does nothing but return false, so it is not necessary to call base.ProcessKey if you derive directly from View, but you should if you derive other View subclasses.

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

    Always use Bounds (view-relative) when calling Redraw(Rect), NOT Frame (superview-relative).

    Views should set the color that they want to use on entry, as otherwise this will inherit the last color that was set globally on the driver.

    Overrides of Redraw(Rect) must ensure they do not set Driver.Clip to a clip region larger than the region parameter.

    Events

    MenuClosing

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

    MenuOpening

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

    Implements

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