IDesktopMenuCommandTarget interface

Namespace Runic.Desktop in Runic.Desktop 0.23.0

public interface IDesktopMenuCommandTarget

Runs the commands of menu items for a window or for the application.

Remarks

Runic Desktop calls both members on the platform's UI thread, while it shows a menu or matches a shortcut: keep IDesktopMenuCommandTarget.CanExecute cheap, for example by answering from state the command updates, and let IDesktopMenuCommandTarget.Execute hand the work to the application's own thread. An item whose DesktopMenuItem.IsEnabled is false is disabled without asking. Runic Windows get one for their root ViewModel through IRunicMenuCommandSource.

Methods

CanExecute

bool CanExecute(DesktopMenuItem item)

Gets whether the item's command can run now; false also for a command this target does not handle.

Parameters

item

The menu item; its DesktopMenuItem.CommandId names the command.

Execute

void Execute(DesktopMenuItem item)

Runs the item's command, after IDesktopMenuCommandTarget.CanExecute returned true.

Parameters

item

The menu item; its DesktopMenuItem.CommandId names the command.

IsChecked

bool? IsChecked(DesktopMenuItem item)

Gets whether a check or radio item shows its check mark now.

Parameters

item

The menu item; its DesktopMenuItem.CommandId and DesktopMenuItem.CommandParameter name the state.

Returns

true or false for an item this target answers for; null, as the default returns, when it has no answer.

Remarks

Runic Desktop asks it only for items declared with a non-null DesktopMenuItem.IsChecked, on the platform's UI thread, where it asks IDesktopMenuCommandTarget.CanExecute: as a menu opens natively, and when the state of an in-page menu bar is built. Answer from state the command updates. The window's target is asked first and the application's next; the first non-null answer, also one equal to the declaration, decides, and without one the item shows its declared DesktopMenuItem.IsChecked. Each item of a radio group is asked on its own, so answer true for exactly one of them.