Class MenuItem
A MenuItem has a title, an associated help text, and an action to execute on activation.
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(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 |
|---|---|---|
| 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. |
| Key | shortcut | The Shortcut keystroke combination. |
MenuItem(Key)
Initializes a new instance of MenuItem
Declaration
public MenuItem(Key shortcut = Key.Null)
Parameters
| Type | Name | Description |
|---|---|---|
| Key | shortcut |
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 |
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 |
Data
Gets or sets arbitrary data for the menu item.
Declaration
public object Data { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Object |
Remarks
This property is not used internally.
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. |
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 { get; set; }
Property Value
| Type | Description |
|---|---|
| Key |
ShortcutTag
The keystroke combination used in the ShortcutTag as string.
Declaration
public ustring ShortcutTag { get; }
Property Value
| Type | Description |
|---|---|
| NStack.ustring |
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 |