#nullable enable
namespace Terminal.Gui;
///
/// A -derived object to be used as items in a .
/// MenuBarItems have a title, a hotkey, and an action to execute on activation.
///
public class MenuBarItemv2 : MenuItemv2
{
///
/// Creates a new instance of .
///
public MenuBarItemv2 () : base (null, Command.NotBound) { }
///
/// Creates a new instance of . Each MenuBarItem typically has a
/// that is
/// shown when the item is selected.
///
///
///
///
/// The View that will be invoked on when user does something that causes the MenuBarItems's
/// Accept event to be raised.
///
///
/// The Command to invoke on . The Key
/// has bound to will be used as
///
/// The text to display for the command.
/// The Popover Menu that will be displayed when this item is selected.
public MenuBarItemv2 (View? targetView, Command command, string? commandText, PopoverMenu? popoverMenu = null)
: base (
targetView,
command,
commandText)
{
TargetView = targetView;
Command = command;
PopoverMenu = popoverMenu;
}
///
/// Creates a new instance of with the specified . This is a
/// helper for the most common MenuBar use-cases.
///
///
///
/// The text to display for the command.
/// The Popover Menu that will be displayed when this item is selected.
public MenuBarItemv2 (string commandText, PopoverMenu? popoverMenu = null)
: this (
null,
Command.NotBound,
commandText,
popoverMenu)
{ }
///
/// Creates a new instance of with the automatcialy added to a
/// .
/// This is a helper for the most common MenuBar use-cases.
///
///
///
/// The text to display for the command.
///
/// The menu items that will be added to the Popover Menu that will be displayed when this item is
/// selected.
///
public MenuBarItemv2 (string commandText, IEnumerable menuItems)
: this (
null,
Command.NotBound,
commandText,
new (menuItems))
{ }
// TODO: Hide base.SubMenu?
///
/// The Popover Menu that will be displayed when this item is selected.
///
public PopoverMenu? PopoverMenu { get; set; }
///
protected override void Dispose (bool disposing)
{
if (disposing)
{
PopoverMenu?.Dispose ();
PopoverMenu = null;
}
base.Dispose (disposing);
}
}