Class ContextMenu
ContextMenu provides a pop-up menu that can be positioned anywhere within a View.
ContextMenu is analogous to MenuBar and, once activated, works like a sub-menu
of a MenuBarItem (but can be positioned anywhere).
By default, a ContextMenu with sub-menus is displayed in a cascading manner, where each sub-menu pops out of the ContextMenu frame (either to the right or left, depending on where the ContextMenu is relative to the edge of the screen). By setting UseSubMenusSingleFrame to true, this behavior can be changed such that all sub-menus are drawn within the ContextMenu frame.
ContextMenus can be activated using the Shift-F10 key (by default; use the Key to change to another key).
Callers can cause the ContextMenu to be activated on a right-mouse click (or other interaction) by calling Show().
ContextMenus are located using screen using screen coordinates and appear above all other Views.
Inheritance
System.Object
ContextMenu
Implements
System.IDisposable
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 sealed class ContextMenu : IDisposable
Constructors
| Improve this Doc View SourceContextMenu()
Initializes a context menu with no menu items.
Declaration
public ContextMenu()
ContextMenu(Int32, Int32, MenuBarItem)
Initializes a context menu with menu items at a specific screen location.
Declaration
public ContextMenu(int x, int y, MenuBarItem menuItems)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The left position (screen relative). |
System.Int32 | y | The top position (screen relative). |
MenuBarItem | menuItems | The menu items. |
ContextMenu(View, MenuBarItem)
Initializes a context menu, with a View specifiying the parent/hose of the menu.
Declaration
public ContextMenu(View host, MenuBarItem menuItems)
Parameters
Type | Name | Description |
---|---|---|
View | host | The host view. |
MenuBarItem | menuItems | The menu items for the context menu. |
Properties
| Improve this Doc View SourceForceMinimumPosToZero
Sets or gets whether the context menu be forced to the right, ensuring it is not clipped, if the x position
is less than zero. The default is true which means the context menu will be forced to the right.
If set to false, the context menu will be clipped on the left if x is less than zero.
Declaration
public bool ForceMinimumPosToZero { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Host
The host View which position will be used,
otherwise if it's null the container will be used.
Declaration
public View Host { get; set; }
Property Value
Type | Description |
---|---|
View |
IsShow
Gets whether the ContextMenu is showing or not.
Declaration
public static bool IsShow { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Key
Key specifies they keyboard key that will activate the context menu with the keyboard.
Declaration
public Key Key { get; set; }
Property Value
Type | Description |
---|---|
Key |
MenuBar
Gets the MenuBar that is hosting this context menu.
Declaration
public MenuBar MenuBar { get; }
Property Value
Type | Description |
---|---|
MenuBar |
MenuItems
Gets or sets the menu items for this context menu.
Declaration
public MenuBarItem MenuItems { get; set; }
Property Value
Type | Description |
---|---|
MenuBarItem |
MouseFlags
MouseFlags specifies the mouse action used to activate the context menu by mouse.
Declaration
public MouseFlags MouseFlags { get; set; }
Property Value
Type | Description |
---|---|
MouseFlags |
Position
Gets or sets the menu position.
Declaration
public Point Position { get; set; }
Property Value
Type | Description |
---|---|
Point |
UseSubMenusSingleFrame
Gets or sets if sub-menus will be displayed using a "single frame" menu style. If true, the ContextMenu
and any sub-menus that would normally cascade will be displayed within a single frame. If false (the default),
sub-menus will cascade using separate frames for each level of the menu hierarchy.
Declaration
public bool UseSubMenusSingleFrame { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceDispose()
Disposes the context menu object.
Declaration
public void Dispose()
Hide()
Hides (closes) the ContextMenu.
Declaration
public void Hide()
Show()
Shows (opens) the ContextMenu, displaying the MenuItems it contains.
Declaration
public void Show()
Events
| Improve this Doc View SourceKeyChanged
Event invoked when the Key is changed.
Declaration
public event Action<Key> KeyChanged
Event Type
Type | Description |
---|---|
System.Action<Key> |
MouseFlagsChanged
Event invoked when the MouseFlags is changed.
Declaration
public event Action<MouseFlags> MouseFlagsChanged
Event Type
Type | Description |
---|---|
System.Action<MouseFlags> |
Implements
System.IDisposable