Table of Contents

Class PopoverMenu

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

A IPopover-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 : Popover<Menu, MenuItem>, IDisposable, ISupportInitializeNotification, ISupportInitialize, IPopoverView, IPopover, IDesignable
Inheritance
PopoverMenu
Implements
Inherited Members
Extension Methods

Remarks

IMPORTANT: Must be registered with Popovers via Register(IPopoverView?) before calling MakeVisible(Point?, Rectangle?) or Show(IPopoverView?).

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 https://gui-cs.github.io/Terminal.Gui/docs/popovers.html for more information.

Default key bindings:

KeyAction
RightOpens a sub-menu or moves to the next menu bar item.
LeftCloses a sub-menu or moves to the previous menu bar item.

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. The root menu is added as the first Subview of the PopoverMenu.

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.

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.

OnActivated(ICommandContext?)

Called when the View has been activated. This is called after Accepting has been raised and not cancelled.

OnActivating(CommandEventArgs)

Called when the user has performed an action (e.g. Activate) causing the View to change state or preparing it for interaction. 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 the Visible property has changed. Hides the popover via ApplicationPopover when becoming invisible.

Events

KeyChanged

Raised when the Key property is changed.