Table of Contents

Class PopoverMenu

Namespace
Terminal.Gui.Views
Assembly
Terminal.Gui.dll

A PopoverBaseImpl-derived view that provides a cascading menu. Can be used as a context menu or a drop-down menu as part of MenuBar.

public class PopoverMenu : PopoverBaseImpl, IDisposable, ISupportInitializeNotification, ISupportInitialize, IPopover, IDesignable
Inheritance
PopoverMenu
Implements
Inherited Members
Extension Methods

Remarks

IMPORTANT: Must be registered with Popover via Register(IPopover?) before calling MakeVisible(Point?) or Show(IPopover?).

Usage Example:

var menu = new PopoverMenu ([
    new MenuItem ("Cut", Command.Cut),
    new MenuItem ("Copy", Command.Copy),
    new MenuItem ("Paste", Command.Paste)
]);
Application.Popover?.Register (menu);
menu.MakeVisible (); // or Application.Popover?.Show (menu);

See PopoverBaseImpl and IPopover for lifecycle, focus, and keyboard handling details.

Constructors

PopoverMenu()

Initializes a new instance of the PopoverMenu class.

PopoverMenu(IEnumerable<View>?)

Initializes a new instance of the PopoverMenu class. If any of the elements of menuItems is null, a Line will be created instead.

PopoverMenu(IEnumerable<MenuItem>?)

Initializes a new instance of the PopoverMenu class with the specified menu items.

PopoverMenu(Menu?)

Initializes a new instance of the PopoverMenu class with the specified root Menu.

Properties

DefaultKey

Gets or sets the default key for activating popover menus. The default value is F10 with Shift.

Key

Gets or sets the key that will activate the popover menu when it is registered but not visible.

MouseFlags

The mouse flags that will cause the popover menu to be visible. The default is RightButtonClicked which is typically the right mouse button.

Root

Gets or sets the Menu that is the root of the popover menu hierarchy.

Methods

Dispose(bool)

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

EnableForDesign<TContext>(ref TContext)

Enables the popover menu for use in design-time scenarios.

GetAllSubMenus()

Gets all the submenus in the popover menu hierarchy, including the root menu.

MakeVisible(Point?)

Makes the popover menu visible and locates it at idealScreenPosition. The actual position of the menu will be adjusted to ensure the menu fully fits on the screen, with the mouse cursor positioned over the first cell of the first MenuItem.

OnAccepting(CommandEventArgs)

Called when the user is accepting the state of the View and the Accept has been invoked. Set CommandEventArgs.Handled to true and return true to indicate the event was handled and processing should stop.

OnKeyDownNotHandled(Key)

Called when the user has pressed key it wasn't handled by KeyDown and was not bound to a key binding.

OnSubViewAdded(View)

Called when a SubView has been added to this View.

OnVisibleChanged()

Called when Visible has changed.

SetPosition(Point?)

Sets the position of the popover menu at idealScreenPosition. The actual position will be adjusted to ensure the menu fully fits on the screen, with the mouse cursor positioned over the first cell of the first MenuItem (if possible).

Events

KeyChanged

Raised when the Key property is changed.