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()
Initializes a new instance of MenuItem
Declaration
public MenuItem()
MenuItem(ustring, String, Action, Func<Boolean>)
Initializes a new instance of MenuItem.
Declaration
public MenuItem(ustring title, string help, Action action, Func<bool> canExecute = null)
Parameters
Type | Name | Description |
---|---|---|
NStack.ustring | title | Title for the menu item. |
System.String | 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 executred. |
MenuItem(ustring, MenuBarItem)
Initializes a new instance of MenuItem
Declaration
public MenuItem(ustring title, MenuBarItem subMenu)
Parameters
Type | Name | Description |
---|---|---|
NStack.ustring | title | Title for the menu item. |
MenuBarItem | subMenu | The menu sub-menu. |
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. |
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. |
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 |