Class MenuItem | Terminal.Gui v2 (original) (raw)

Namespace

Terminal.Gui

Assembly

Terminal.Gui.dll

A MenuItem has title, an associated help text, and an action to execute on activation. MenuItems can also have a checked indicator (see Checked).

[Obsolete("Use MenuItemv2 instead.", false)]
public class MenuItem

Inheritance

MenuItem

Derived

Inherited Members

Constructors

MenuItem(string?, string?, Action?, Func?, MenuItem?, Key?)

Initializes a new instance of MenuItem.

MenuItem(Key?)

Initializes a new instance of MenuItem

Properties

Action

Gets or sets the action to be invoked when the menu item is triggered.

AllowNullChecked

Used only if CheckType is of Checked type. Iftrue allows Checked to be null, true or false. If false only allows Checked to be true or false.

CanExecute

Gets or sets the action to be invoked to determine if the menu can be triggered. If CanExecutereturns true the menu item will be enabled. Otherwise, it will be disabled.

CheckType

Sets or gets the MenuItemCheckStyle of a menu item where Checked is set totrue.

Checked

Sets or gets whether the MenuItem shows a check indicator or not. SeeMenuItemCheckStyle.

Data

Gets or sets arbitrary data for the menu item.

Help

Gets or sets the help text for the menu item. The help text is drawn to the right of the Title.

HotKey

The HotKey is used to activate a MenuItem with the keyboard. HotKeys are defined by prefixing theTitle 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 ShortcutKey which enable global key-bindings to menu items.

Parent

Gets the parent for this MenuItem.

ShortcutKey

Shortcut defines a key binding to the MenuItem that will invoke the MenuItem's action globally for theView that is the parent of the MenuBar thisMenuItem.

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

ShortcutTag

Gets the text describing the keystroke combination defined by ShortcutKey.

Title

Gets or sets the title of the menu item .

Methods

IsEnabled()

Returns true if the menu item is enabled. This method is a wrapper aroundCanExecute.

RemoveMenuItem()

Removes a MenuItem dynamically from the Parent.

ToggleChecked()

Toggle the Checked between three states if AllowNullChecked istrue or between two states if AllowNullChecked is false.