diff --git a/Examples/UICatalog/Scenarios/Menus.cs b/Examples/UICatalog/Scenarios/Menus.cs
index 4796473ac..f044749ba 100644
--- a/Examples/UICatalog/Scenarios/Menus.cs
+++ b/Examples/UICatalog/Scenarios/Menus.cs
@@ -347,6 +347,8 @@ public class Menus : Scenario
};
ContextMenu.EnableForDesign (ref host);
+ Application.Popover.Register (ContextMenu);
+
ContextMenu.Visible = false;
// Demo of PopoverMenu as a context menu
diff --git a/Terminal.Gui/App/IPopover.cs b/Terminal.Gui/App/IPopover.cs
index be577b871..00ff8087b 100644
--- a/Terminal.Gui/App/IPopover.cs
+++ b/Terminal.Gui/App/IPopover.cs
@@ -8,54 +8,64 @@ namespace Terminal.Gui.App;
///
/// A popover is a transient UI element that appears above other content to display contextual information or UI,
/// such as menus, tooltips, or dialogs.
-/// Popovers are managed by and are typically shown using
-/// .
///
///
-/// Popovers are not modal; they do not block input to the rest of the application, but they do receive focus and
-/// input events while visible.
-/// When a popover is shown, it is responsible for handling its own layout and content.
+/// IMPORTANT: Popovers must be registered with using
+/// before they can be shown with .
///
///
+/// Lifecycle:
+/// When registered, the popover's lifetime is managed by the application. Registered popovers are
+/// automatically disposed when is called. Call
+/// to manage the lifetime directly.
+///
+///
+/// Visibility and Hiding:
/// Popovers are automatically hidden when:
-///
-/// - The user clicks outside the popover (unless occluded by a subview of the popover).
-/// - The user presses (typically Esc).
-/// - Another popover is shown.
-///
///
+///
+/// - The user clicks outside the popover (unless clicking on a subview).
+/// - The user presses (typically Esc).
+/// - Another popover is shown.
+/// - is set to .
+///
///
/// Focus and Input:
-/// When visible, a popover receives focus and input events. If the user clicks outside the popover (and not on a
-/// subview),
-/// presses , or another popover is shown, the popover will be hidden
-/// automatically.
+/// Popovers are not modal but do receive focus and input events while visible.
+/// Registered popovers receive keyboard events even when not visible, enabling global hotkey support.
///
///
/// Layout:
-/// When the popover becomes visible, it is automatically laid out to fill the screen by default. You can override
-/// this behavior
-/// by setting and in your derived class.
+/// When becoming visible, popovers are automatically laid out to fill the screen by default.
+/// Override and to customize size.
///
///
-/// Mouse:
-/// Popovers are transparent to mouse events (see ),
-/// meaning mouse events in a popover that are not also within a subview of the popover will not be captured.
+/// Mouse Events:
+/// Popovers use , meaning mouse events
+/// outside subviews are not captured.
///
///
-/// Custom Popovers:
-/// To create a custom popover, inherit from and add your own content and logic.
+/// Creating Custom Popovers:
+/// Inherit from and add your own content and logic.
///
///
public interface IPopover
{
///
- /// Gets or sets the that this Popover is associated with. If null, it is not associated with
- /// any Runnable and will receive all keyboard
- /// events from the . If set, it will only receive keyboard events the Runnable would normally
- /// receive.
- /// When is called, the is set to the current
- /// if not already set.
+ /// Gets or sets the that this popover is associated with.
///
+ ///
+ ///
+ /// If , the popover is not associated with any runnable and will receive all keyboard
+ /// events from the application.
+ ///
+ ///
+ /// If set, the popover will only receive keyboard events when the associated runnable is active.
+ ///
+ ///
+ /// When is called, this property is automatically set to
+ /// if not already set.
+ ///
+ ///
IRunnable? Current { get; set; }
}
diff --git a/Terminal.Gui/App/PopoverBaseImpl.cs b/Terminal.Gui/App/PopoverBaseImpl.cs
index ff118df35..81673e405 100644
--- a/Terminal.Gui/App/PopoverBaseImpl.cs
+++ b/Terminal.Gui/App/PopoverBaseImpl.cs
@@ -2,36 +2,36 @@
namespace Terminal.Gui.App;
///
-/// Abstract base class for popover views in Terminal.Gui.
+/// Abstract base class for popover views in Terminal.Gui. Implements .
///
///
///
-/// Popover Lifecycle:
-/// To display a popover, use . To hide a popover, either call
-/// ,
-/// set to , or show another popover.
+/// IMPORTANT: Popovers must be registered with using
+/// before they can be shown.
///
///
-/// Focus and Input:
-/// When visible, a popover receives focus and input events. If the user clicks outside the popover (and not on a
-/// subview),
-/// presses , or another popover is shown, the popover will be hidden
-/// automatically.
+/// Requirements:
+/// Derived classes must:
///
+///
+/// - Set to include and .
+/// - Add a key binding for (typically bound to ).
+///
///
-/// Layout:
-/// When the popover becomes visible, it is automatically laid out to fill the screen by default. You can override
-/// this behavior
-/// by setting and in your derived class.
+/// Default Behavior:
+/// This base class provides:
///
+///
+/// - Fills the screen by default ( = , = ).
+/// - Transparent viewport settings for proper mouse event handling.
+/// - Automatic layout when becoming visible.
+/// - Focus restoration when hidden.
+/// - Default implementation that hides the popover.
+///
///
-/// Mouse:
-/// Popovers are transparent to mouse events (see ),
-/// meaning mouse events in a popover that are not also within a subview of the popover will not be captured.
-///
-///
-/// Custom Popovers:
-/// To create a custom popover, inherit from and add your own content and logic.
+/// Lifecycle:
+/// Use to display and or
+/// set to to hide.
///
///
public abstract class PopoverBaseImpl : View, IPopover
@@ -40,7 +40,15 @@ public abstract class PopoverBaseImpl : View, IPopover
/// Initializes a new instance of the class.
///
///
- /// By default, the popover fills the available screen area and is focusable.
+ ///
+ /// Sets up default popover behavior:
+ ///
+ ///
+ /// - Fills the screen ( = , = ).
+ /// - Sets to .
+ /// - Configures with and .
+ /// - Adds bound to which hides the popover when invoked.
+ ///
///
protected PopoverBaseImpl ()
{
@@ -87,15 +95,19 @@ public abstract class PopoverBaseImpl : View, IPopover
}
///
- /// Called when the property is changing.
+ /// Called when the property is changing. Handles layout and focus management.
///
- ///
- /// When becoming visible, the popover is laid out to fit the screen.
- /// When becoming hidden, focus is restored to the previous view.
- ///
///
/// to cancel the visibility change; otherwise, .
///
+ ///
+ ///
+ /// When becoming visible: Lays out the popover to fit the screen.
+ ///
+ ///
+ /// When becoming hidden: Restores focus to the previously focused view in the view hierarchy.
+ ///
+ ///
protected override bool OnVisibleChanging ()
{
bool ret = base.OnVisibleChanging ();
diff --git a/Terminal.Gui/Views/Menu/PopoverMenu.cs b/Terminal.Gui/Views/Menu/PopoverMenu.cs
index 7f1e45979..acd3c2bd6 100644
--- a/Terminal.Gui/Views/Menu/PopoverMenu.cs
+++ b/Terminal.Gui/Views/Menu/PopoverMenu.cs
@@ -1,16 +1,29 @@
-
-
namespace Terminal.Gui.Views;
///
-/// Provides a cascading menu that pops over all other content. Can be used as a context menu or a drop-down
-/// all other content. Can be used as a context menu or a drop-down
-/// menu as part of as part of .
+/// A -derived view that provides a cascading menu.
+/// Can be used as a context menu or a drop-down menu as part of .
///
///
///
-/// To use as a context menu, register the popover menu with and call
-/// .
+/// IMPORTANT: Must be registered with via
+/// before calling or
+/// .
+///
+///
+/// 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 and for lifecycle, focus, and keyboard handling details.
///
///
public class PopoverMenu : PopoverBaseImpl, IDesignable
@@ -22,9 +35,12 @@ public class PopoverMenu : PopoverBaseImpl, IDesignable
///
/// Initializes a new instance of the class. If any of the elements of
- /// is ,
- /// a see will be created instead.
+ /// is , a will be created instead.
///
+ /// The views to use as menu items. Null elements become separator lines.
+ ///
+ /// Remember to call before calling .
+ ///
public PopoverMenu (IEnumerable? menuItems) : this (
new Menu (menuItems?.Select (item => item ?? new Line ()))
{
@@ -32,17 +48,27 @@ public class PopoverMenu : PopoverBaseImpl, IDesignable
})
{ }
- ///
+ ///
+ /// Initializes a new instance of the class with the specified menu items.
+ ///
+ /// The menu items to display in the popover.
+ ///
+ /// Remember to call before calling .
+ ///
public PopoverMenu (IEnumerable