Table of Contents

Class ContextMenu

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

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(MenuBarItem?).

ContextMenus are located using screen coordinates and appear above all other Views.

public sealed class ContextMenu : IDisposable
Inheritance
ContextMenu
Implements
Inherited Members

Constructors

ContextMenu()

Initializes a context menu with no menu items.

Properties

DefaultKey

The default shortcut key for activating the context menu.

ForceMinimumPosToZero

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.

Host

The host View which position will be used, otherwise if it's null the container will be used.

IsShow

Gets whether the ContextMenu is showing or not.

Key

Specifies the key that will activate the context menu.

MenuBar

Gets the MenuBar that is hosting this context menu.

MenuItems

Gets or sets the menu items for this context menu.

MouseFlags

MouseFlags specifies the mouse action used to activate the context menu by mouse.

Position

Gets or sets the menu position.

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.

Methods

Dispose()

Disposes the context menu object.

Hide()

Hides (closes) the ContextMenu.

Show(MenuBarItem?)

Shows (opens) the ContextMenu, displaying the MenuItems it contains.

Events

KeyChanged

Event invoked when the Key is changed.

MouseFlagsChanged

Event invoked when the MouseFlags is changed.