Search Results for

    Show / Hide Table of Contents

    Class MenuItem

    A MenuItem has title, an associated help text, and an action to execute on activation. MenuItems can also have a checked indicator (see Checked).
    Inheritance
    System.Object
    MenuItem
    MenuBarItem
    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)
    System.Object.ToString()
    Namespace: Terminal.Gui
    Assembly: Terminal.Gui.dll
    Syntax
    public class MenuItem

    Constructors

    | Improve this Doc View Source

    MenuItem(Key)

    Initializes a new instance of MenuItem
    Declaration
    public MenuItem(Key shortcut = Key.Null)
    Parameters
    Type Name Description
    Key shortcut
    | Improve this Doc View Source

    MenuItem(ustring, ustring, Action, Func<Boolean>, MenuItem, Key)

    Initializes a new instance of MenuItem.
    Declaration
    public MenuItem(ustring title, ustring help, Action action, Func<bool> canExecute = null, MenuItem parent = null, Key shortcut = Key.Null)
    Parameters
    Type Name Description
    ustring title Title for the menu item.
    ustring help Help text to display.
    System.Action action Action to invoke when the menu item is activated.
    System.Func<System.Boolean> canExecute Function to determine if the action can currently be executed.
    MenuItem parent The Parent of this menu item.
    Key shortcut The Shortcut keystroke combination.

    Fields

    | Improve this Doc View Source

    HotKey

    The HotKey is used to activate a MenuItem with the keyboard. HotKeys are defined by prefixing the Title of a MenuItem with an underscore ('_').

    Pressing Alt-Hotkey for a MenuBarItem (menu items on the menu bar) works even if the menu is not active). Once a menu has focus and is active, pressing just the HotKey will activate the MenuItem.

    For example for a MenuBar with a "_File" MenuBarItem that contains a "_New" MenuItem, Alt-F will open the File menu. Pressing the N key will then activate the New MenuItem.

    See also Shortcut which enable global key-bindings to menu items.

    Declaration
    public Rune HotKey
    Field Value
    Type Description
    Rune

    Properties

    | Improve this Doc View Source

    Action

    Gets or sets the action to be invoked when the menu item is triggered.
    Declaration
    public Action Action { get; set; }
    Property Value
    Type Description
    System.Action Method to invoke.
    | Improve this Doc View Source

    CanExecute

    Gets or sets the action to be invoked to determine if the menu can be triggered. If CanExecute returns true the menu item will be enabled. Otherwise, it will be disabled.
    Declaration
    public Func<bool> CanExecute { get; set; }
    Property Value
    Type Description
    System.Func<System.Boolean> Function to determine if the action is can be executed or not.
    | Improve this Doc View Source

    Checked

    Sets or gets whether the MenuItem shows a check indicator or not. See MenuItemCheckStyle.
    Declaration
    public bool Checked { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    CheckType

    Sets or gets the MenuItemCheckStyle of a menu item where Checked is set to true.
    Declaration
    public MenuItemCheckStyle CheckType { get; set; }
    Property Value
    Type Description
    MenuItemCheckStyle
    | Improve this Doc View Source

    Data

    Gets or sets arbitrary data for the menu item.
    Declaration
    public object Data { get; set; }
    Property Value
    Type Description
    System.Object
    | Improve this Doc View Source

    Help

    Gets or sets the help text for the menu item. The help text is drawn to the right of the Title.
    Declaration
    public ustring Help { get; set; }
    Property Value
    Type Description
    ustring The help text.
    | Improve this Doc View Source

    Parent

    Gets the parent for this MenuItem.
    Declaration
    public MenuItem Parent { get; }
    Property Value
    Type Description
    MenuItem The parent.
    | Improve this Doc View Source

    Shortcut

    Shortcut defines a key binding to the MenuItem that will invoke the MenuItem's action globally for the View that is the parent of the MenuBar or ContextMenu this MenuItem.

    The Key will be drawn on the MenuItem to the right of the Title and Help text. See ShortcutTag.

    Declaration
    public Key Shortcut { get; set; }
    Property Value
    Type Description
    Key
    | Improve this Doc View Source

    ShortcutTag

    Gets the text describing the keystroke combination defined by Shortcut.
    Declaration
    public ustring ShortcutTag { get; }
    Property Value
    Type Description
    ustring
    | Improve this Doc View Source

    Title

    Gets or sets the title of the menu item .
    Declaration
    public ustring Title { get; set; }
    Property Value
    Type Description
    ustring The title.

    Methods

    | Improve this Doc View Source

    GetMenuBarItem()

    Merely a debugging aid to see the interaction with main.
    Declaration
    public bool GetMenuBarItem()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    GetMenuItem()

    Merely a debugging aid to see the interaction with main.
    Declaration
    public MenuItem GetMenuItem()
    Returns
    Type Description
    MenuItem
    | Improve this Doc View Source

    IsEnabled()

    Returns true if the menu item is enabled. This method is a wrapper around CanExecute.
    Declaration
    public bool IsEnabled()
    Returns
    Type Description
    System.Boolean
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX