MenuBarController interface

Module @runic-artifex/views in @runic-artifex/views 0.23.0

interface MenuBarController

The headless in-page menu bar. Framework adapters wrap it in their reactive state.

Properties

current

readonly current: MenuBarState;

The current state.

Methods

subscribe

subscribe(listener: () => void): () => void;

Calls listener after each change of current, until the returned function is called.

onRequest

onRequest(listener: (request: MenuBarRequest) => void): () => void;

Calls listener with each keyboard request, until the returned function is called.

invoke

invoke(item: MenuBarItem): Promise<MenuBarInvokeResult>;

Runs an item as the native menu bar does: the window's command, then the application's, if it can run now. Rejects with a BridgeError when the host cannot be reached.

handleKeyDown

handleKeyDown(event: ShortcutEvent & {
    readonly defaultPrevented?: boolean;
    preventDefault(): void;
}): boolean;

Matches a keydown event against the enabled items' shortcuts. On a match it calls preventDefault(), invokes the item and returns true. Events that are defaultPrevented or part of a composition never match. For the shortcuts: "app" option.

dispose

dispose(): void;

Stops following the host, ends the "app" lease and removes the keyboard listeners.