Show / Hide Table of Contents

# Class MenuItem

A MenuItem has a title, an associated help text, and an action to execute on activation.

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

#### MenuItem()

Initializes a new instance of MenuItem

##### Declaration

    public MenuItem()

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

Initializes a new instance of MenuItem.

##### Declaration

    public MenuItem(ustring title, ustring help, Action action, Func<bool> canExecute = null, MenuItem parent = null)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | title | Title for the menu item.
NStack.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.

### Fields

#### HotKey

The HotKey is used when the menu is active, the shortcut can be triggered when the menu is not active. For example HotKey would be "N" when the File Menu is open (assuming there is a "_New" entry if the ShortCut is set to "Control-N", this would be a global hotkey that would trigger as well

##### Declaration

    public Rune HotKey

##### Field Value

Type | Description
--- | ---
System.Rune |

#### ShortCut

This is the global setting that can be used as a global shortcut to invoke the action on the menu.

##### Declaration

    public Key ShortCut

##### Field Value

Type | Description
--- | ---
Key |

### Properties

#### Action

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

##### Declaration

    public Action Action { get; set; }

##### Property Value

Type | Description
--- | ---
System.Action | Method to invoke.

#### CanExecute

Gets or sets the action to be invoked if the menu can be triggered

##### Declaration

    public Func<bool> CanExecute { get; set; }

##### Property Value

Type | Description
--- | ---
System.Func<System.Boolean> | Function to determine if action is ready to be executed.

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

#### CheckType

Sets or gets the type selection indicator the menu item will be displayed with.

##### Declaration

    public MenuItemCheckStyle CheckType { get; set; }

##### Property Value

Type | Description
--- | ---
MenuItemCheckStyle |

#### Help

Gets or sets the help text for the menu item.

##### Declaration

    public ustring Help { get; set; }

##### Property Value

Type | Description
--- | ---
NStack.ustring | The help text.

#### Parent

Gets or sets the parent for this MenuItem.

##### Declaration

    public MenuItem Parent { get; }

##### Property Value

Type | Description
--- | ---
MenuItem | The parent.

#### Title

Gets or sets the title.

##### Declaration

    public ustring Title { get; set; }

##### Property Value

Type | Description
--- | ---
NStack.ustring | The title.

### Methods

#### GetMenuBarItem()

Merely a debugging aid to see the interaction with main

##### Declaration

    public bool GetMenuBarItem()

##### Returns

Type | Description
--- | ---
System.Boolean |

#### GetMenuItem()

Merely a debugging aid to see the interaction with main

##### Declaration

    public MenuItem GetMenuItem()

##### Returns

Type | Description
--- | ---
MenuItem |

#### IsEnabled()

Shortcut to check if the menu item is enabled

##### Declaration

    public bool IsEnabled()

##### Returns

Type | Description
--- | ---
System.Boolean |