Search Results for

    Show / Hide Table of Contents

    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
    object
    ContextMenu
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Terminal.Gui
    Assembly: Terminal.Gui.dll
    Syntax
    public sealed class ContextMenu : IDisposable

    Constructors

    | Edit this page View Source

    ContextMenu()

    Initializes a context menu with no menu items.
    Declaration
    public ContextMenu()
    | Edit this page View Source

    ContextMenu(int, int, 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
    int x The left position (screen relative).
    int y The top position (screen relative).
    MenuBarItem menuItems The menu items.
    | Edit this page View Source

    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

    | Edit this page View Source

    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.
    Declaration
    public bool ForceMinimumPosToZero { get; set; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    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
    | Edit this page View Source

    IsShow

    Gets whether the ContextMenu is showing or not.
    Declaration
    public static bool IsShow { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    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
    | Edit this page View Source

    MenuBar

    Gets the MenuBar that is hosting this context menu.
    Declaration
    public MenuBar MenuBar { get; }
    Property Value
    Type Description
    MenuBar
    | Edit this page View Source

    MenuItems

    Gets or sets the menu items for this context menu.
    Declaration
    public MenuBarItem MenuItems { get; set; }
    Property Value
    Type Description
    MenuBarItem
    | Edit this page View Source

    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
    | Edit this page View Source

    Position

    Gets or sets the menu position.
    Declaration
    public Point Position { get; set; }
    Property Value
    Type Description
    Point
    | Edit this page View Source

    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
    bool

    Methods

    | Edit this page View Source

    Dispose()

    Disposes the context menu object.
    Declaration
    public void Dispose()
    | Edit this page View Source

    Hide()

    Hides (closes) the ContextMenu.
    Declaration
    public void Hide()
    | Edit this page View Source

    Show()

    Shows (opens) the ContextMenu, displaying the MenuItems it contains.
    Declaration
    public void Show()

    Events

    | Edit this page View Source

    KeyChanged

    Event invoked when the Key is changed.
    Declaration
    public event Action<Key> KeyChanged
    Event Type
    Type Description
    Action<Key>
    | Edit this page View Source

    MouseFlagsChanged

    Event invoked when the MouseFlags is changed.
    Declaration
    public event Action<MouseFlags> MouseFlagsChanged
    Event Type
    Type Description
    Action<MouseFlags>

    Implements

    IDisposable
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX