public sealed record DesktopMenuItem : DesktopMenuEntry, IEquatable<DesktopMenuItem> A menu item that runs a command.
Parameters
TitleThe visible title, literal text in the user's language: not blank, at most 128 characters. Mnemonic markers such as
&or_are shown as written; setDesktopMenuItem.AccessKeyfor an access key.CommandIdThe command the item runs: an application-owned routing key, never a command line. It has 1 to 64 ASCII letters, digits, dots, underscores or hyphens; ids starting with
runic.are reserved for Runic's standard commands, of which a menu bar item may nameDesktopMenuItem.OpenDevToolsCommandId.
Remarks
In the menu bar the key window's command target, or the application's, runs the item, and the same command id may appear on more than one item. A context menu returns the chosen item. In a status icon menu choosing the item raises IDesktopStatusIcon.Activated with its DesktopStatusIconActivation.CommandId and DesktopStatusIconActivation.CommandParameter, and command ids are unique.
Constructors
DesktopMenuItem
public DesktopMenuItem(string Title, string CommandId) A menu item that runs a command.
Parameters
TitleThe visible title, literal text in the user's language: not blank, at most 128 characters. Mnemonic markers such as
&or_are shown as written; setDesktopMenuItem.AccessKeyfor an access key.CommandIdThe command the item runs: an application-owned routing key, never a command line. It has 1 to 64 ASCII letters, digits, dots, underscores or hyphens; ids starting with
runic.are reserved for Runic's standard commands, of which a menu bar item may nameDesktopMenuItem.OpenDevToolsCommandId.
Remarks
In the menu bar the key window's command target, or the application's, runs the item, and the same command id may appear on more than one item. A context menu returns the chosen item. In a status icon menu choosing the item raises IDesktopStatusIcon.Activated with its DesktopStatusIconActivation.CommandId and DesktopStatusIconActivation.CommandParameter, and command ids are unique.
Fields
OpenDevToolsCommandId
public const string OpenDevToolsCommandId = "runic.devtools.open" The standard command that opens the key window's developer tools: runic.devtools.open, the one command id with the reserved runic. prefix that a menu bar item may name.
Remarks
Runic Desktop runs it itself, before the window's and the application's command targets: it opens WebView2's DevTools window on Windows and WebKit's Web Inspector on Linux (GTK 3 and GTK 4). The item is disabled outside Development, in a window whose developer tools are off (DesktopWebContentPolicy.DevTools), on macOS (WKWebView opens its Web Inspector only from Safari), in an installed browser, on CS-WebUI and in a custom window host. Context menus and status icon menus do not accept it.
Properties
AccessKey
public char? AccessKey { get; init; } Gets the item's access key, a letter or digit of the title's language, or null for none.
Remarks
Windows and Linux underline it in the title and choose the item with the key while its menu is open; Runic places the marker, so the title stays literal text. When the title does not contain the key, it is shown after the title, as in Enregistrer (S). macOS and status icon menus ignore it.
CommandId
public string CommandId { get; init; } The command the item runs: an application-owned routing key, never a command line. It has 1 to 64 ASCII letters, digits, dots, underscores or hyphens; ids starting with runic. are reserved for Runic's standard commands, of which a menu bar item may name DesktopMenuItem.OpenDevToolsCommandId.
CommandParameter
public string? CommandParameter { get; init; } Gets the text passed to the item's command, or null for none: at most 1024 characters, without NUL.
Remarks
The command target receives the item and reads it with DesktopMenuItem.CommandId, so one command can serve several items, such as a recent file or a zoom level per item. Runic Windows pass it to the ViewModel command's CanExecute and Execute. Like the command id it is an application-owned value: never a command line or a path the application has not checked.
IsChecked
public bool? IsChecked { get; init; } Gets null for a plain item; true or false for a check item and its state.
Remarks
With DesktopMenuItem.RadioGroup set, the item is a radio item and this is whether it is the group's chosen one.
IsEnabled
public bool IsEnabled { get; init; } Gets whether the item can be chosen.
Remarks
In the menu bar the item is enabled while this is true and its command can run.
RadioGroup
public string? RadioGroup { get; init; } Gets the radio group the item belongs to, or null for a plain or check item.
Remarks
The group name follows the command id rule. A radio item needs a non-null DesktopMenuItem.IsChecked; the items of a group are those of one menu level with the same name, and at most one of them is checked (menu-radio-checked otherwise). Windows and Linux show a radio mark; macOS shows the check mark, as AppKit has no radio look. Runic shows the state as declared: choosing an item runs its command, which updates the state and declares the menu again.
Shortcut
public DesktopShortcut? Shortcut { get; init; } Gets the item's keyboard shortcut, or null for none; status icon menus ignore it.
Remarks
On the macOS menu bar it is the item's key equivalent. A shortcut of the standard Edit, Window or application menus, such as ⌘C or ⌘Q, stays theirs: the item is shown without it and DesktopHost.Validate reports menu-shortcut-reserved; Windows and Linux reserve the editing and window shortcuts, such as Ctrl+C and Alt+F4, the same way. The focused page sees a key first and can keep it with preventDefault(). A context menu shows the shortcut as a hint and does not register it.
Title
public string Title { get; init; } The visible title, literal text in the user's language: not blank, at most 128 characters. Mnemonic markers such as & or _ are shown as written; set DesktopMenuItem.AccessKey for an access key.