Search Results for

Show / Hide Table of Contents

# Class ContextMenu

A context menu window derived from MenuBar containing menu items which can be opened in any position.

##### Inheritance

System.Object
ContextMenu

##### Implements

System.IDisposable

###### Namespace: Terminal.Gui

###### Assembly: Terminal.Gui.dll

##### Syntax

    public sealed class ContextMenu : Object

### Constructors

#### ContextMenu()

Initialize a context menu with empty menu items.

##### Declaration

    public ContextMenu()

#### ContextMenu(Int32, Int32, MenuBarItem)

Initialize a context menu with menu items.

##### Declaration

    public ContextMenu(int x, int y, MenuBarItem menuItems)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | x | The left position.
System.Int32 | y | The top position.
MenuBarItem | menuItems | The menu items.

#### ContextMenu(View, MenuBarItem)

Initialize a context menu with menu items from a host View.

##### Declaration

    public ContextMenu(View host, MenuBarItem menuItems)

##### Parameters

Type | Name | Description
--- | --- | ---
View | host | The host view.
MenuBarItem | menuItems | The menu items.

### Properties

#### ForceMinimumPosToZero

Gets or sets whether forces the minimum position to zero if the left or right position are negative.

##### 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 information whether menu is showing or not.

##### Declaration

    public static bool IsShow { get; }

##### Property Value

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

#### Key

The Key used to activate the context menu by 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

The MouseFlags used to activate the context menu by mouse.

##### Declaration

    public MouseFlags MouseFlags { get; set; }

##### Property Value

Type | Description
--- | ---
MouseFlags |

#### Position

Gets or set the menu position.

##### Declaration

    public Point Position { get; set; }

##### Property Value

Type | Description
--- | ---
Point |

#### UseSubMenusSingleFrame

Gets or sets if the sub-menus must be displayed in a single or multiple frames.

##### Declaration

    public bool UseSubMenusSingleFrame { get; set; }

##### Property Value

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

### Methods

#### Dispose()

Disposes the all the context menu objects instances.

##### Declaration

    public void Dispose()

#### Hide()

Close the MenuItems menu items.

##### Declaration

    public void Hide()

#### Show()

Open the MenuItems menu items.

##### Declaration

    public void Show()

### Events

#### KeyChanged

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