using System; using System.Text.Json.Serialization; using System.Runtime.Versioning; namespace ElectronNET.API.Entities { /// /// /// /// Up-to-date with Electron API 39.2 public class MenuItem { /// /// Will be called with click(menuItem, browserWindow, event) when the menu item is /// clicked. /// [JsonIgnore] public Action Click { get; set; } /// /// Gets or sets the action (role) of the menu item. When specified, the click property will be ignored. /// public MenuRole Role { get; set; } /// /// Gets or sets the menu item type. Can be normal, separator, submenu, checkbox, radio, header (macOS 14+), or palette (macOS 14+). /// public MenuType Type { get; set; } /// /// Gets or sets the label. /// /// /// The label. /// public string Label { get; set; } /// /// Gets or sets the sublabel. /// /// /// The sublabel. /// [SupportedOSPlatform("macos")] public string Sublabel { get; set; } /// /// Hover text for this menu item (macOS). /// [SupportedOSPlatform("macos")] public string ToolTip { get; set; } /// /// Gets or sets the accelerator. /// /// /// The accelerator. /// public string Accelerator { get; set; } /// /// Gets or sets the icon. /// /// /// The icon. /// public string Icon { get; set; } /// /// Gets or sets a value indicating whether the item is enabled. If false, the menu item will be greyed out and unclickable. /// public bool Enabled { get; set; } = true; /// /// Gets or sets a value indicating whether the item is visible. If false, the menu item will be entirely hidden. /// public bool Visible { get; set; } = true; /// /// Gets or sets a value indicating whether the accelerator should work when the item is hidden. Default is true (macOS). /// When false, prevents the accelerator from triggering the item if the item is not visible. /// [SupportedOSPlatform("macos")] public bool? AcceleratorWorksWhenHidden { get; set; } /// /// Gets or sets a value indicating whether the accelerator should be registered with the system or only displayed (Linux/Windows). Defaults to true. /// [SupportedOSPlatform("windows")] [SupportedOSPlatform("linux")] public bool? RegisterAccelerator { get; set; } /// /// Gets or sets a value indicating whether the item is checked. Should only be specified for checkbox or radio items. /// public bool Checked { get; set; } /// /// Should be specified for submenu type menu items. If submenu is specified, the /// type: 'submenu' can be omitted.If the value is not a Menu then it will be /// automatically converted to one using Menu.buildFromTemplate. /// public MenuItem[] Submenu { get; set; } /// /// The item to share when the role is shareMenu (macOS). /// [SupportedOSPlatform("macos")] public SharingItem SharingItem { get; set; } /// /// Gets or sets a unique id within a single menu. If defined then it can be used as a reference for placement. /// public string Id { get; internal set; } /// /// This field allows fine-grained definition of the specific location within a given menu. /// public string Position { get; set; } /// /// Gets or sets a list of item ids. Inserts this item before the item(s) with the specified id(s). /// If the referenced item doesn't exist the item will be inserted at the end of the menu. /// Also implies that this item should be placed in the same group as the referenced item(s). /// public string[] Before { get; set; } /// /// Gets or sets a list of item ids. Inserts this item after the item(s) with the specified id(s). /// If the referenced item doesn't exist the item will be inserted at the end of the menu. /// public string[] After { get; set; } /// /// Gets or sets a list of item ids. Places this item's containing group before the containing group /// of the item(s) with the specified id(s). /// public string[] BeforeGroupContaining { get; set; } /// /// Gets or sets a list of item ids. Places this item's containing group after the containing group /// of the item(s) with the specified id(s). /// public string[] AfterGroupContaining { get; set; } } }