/** * Methods for interacting with ToDesktop application's menu. * * @remarks * This package exposes a number of methods for interacting with ToDesktop * application's menu. * @experimental * @public * @packageDocumentation */ import { MenuItemConstructorOptions, PopupOptions } from "@todesktop/client-electron-types"; import { type InstanceRefObject } from "@todesktop/client-util"; import { type Ref } from "./invoke.js"; import { type NamespaceEvents } from "./utils.js"; /** * Creates a new Menu. * * @returns Identifier for the newly created Menu. * @public */ export declare function create(): Promise; /** * Pops up this menu as a context menu in the BrowserWindow. * * @param options - ref: Reference for the Menu. * @public */ export declare function popup({ ref, ...options }: { ref: Ref; } & PopupOptions): Promise; /** * Closes the context menu in the browserWindow. * * @param options - ref: Reference for the Menu. * @public */ export declare function closePopup({ ref, browserWindow, }: { ref: Ref; browserWindow?: InstanceRefObject; }): Promise; /** * Appends the menuItem to the menu. * * @param options - ref: Reference for the Menu. * @public */ export declare function append({ ref, menuItem, }: { ref: Ref; menuItem: InstanceRefObject; }): Promise; /** * Inserts the menuItem to the pos position of the menu. * * @param options - ref: Reference for the Menu. * @public */ export declare function insert({ ref, menuItem, pos, }: { ref: Ref; menuItem: InstanceRefObject; pos: number; }): Promise; /** * Gets the item with the specified id * * @param options - ref: Reference for the Menu; id: string id of the menu. * @public */ export declare function getMenuItemById({ ref, id }: { ref: Ref; id: string; }): Promise; /** * Sets menu as the application menu on macOS. On Windows and Linux, the menu will be set as each window's top menu. * * @param options - menu: Reference for the Menu. * @public */ export declare function setApplicationMenu({ menu }: { menu: Ref; }): Promise; /** * The application menu, if set, or null, if not set. * * @public */ export declare function getApplicationMenu(): Promise; /** * Sends the action to the first responder of application. This is used for emulating default macOS menu behaviors. Usually you would use the role property of a MenuItem. MacOS only. * * @param options - action: string. * @public */ export declare function sendActionToFirstResponder({ action, }: { action: string; }): Promise; /** * Build a new menu from a template of options * * @param options - template: array of options for constructing a MenuItem. * @public */ export declare function buildFromTemplate({ template, }: { template: MenuItemOptions[]; }): Promise; declare type MenuItemOptions = Omit & { click?: (menuItem: InstanceRefObject, browserWindow: InstanceRefObject | undefined, event: KeyboardEvent) => void; icon?: string | InstanceRefObject; submenu?: InstanceRefObject | MenuItemOptions[]; }; /** * @public */ export declare type MenuEvents = NamespaceEvents<{ "menu-will-show": () => void; "menu-will-close": () => void; }>; /** * Subcribes to an event on a menu object. * * @param eventName - The event name to subscribe to. * @param callback - The callback function to execute when the event occurs. * @param options - ref: Reference for the Menu. * @returns unsubscribe callback. * @public */ export declare const on: (eventName: E, callback: NamespaceEvents<{ "menu-will-show": () => void; "menu-will-close": () => void; }>[E], args_0: { ref: InstanceRefObject; preventDefault?: boolean; }) => Promise<() => Promise>; /** * Unsubscribes all menu objects from the event name. * * @param options - ref: Reference for the Menu; eventName: The event name to unsubscribe from; * @returns Reference for the menu. * @public */ export declare const removeAllListeners: (eventName: E, args_0: { ref: InstanceRefObject; }) => Promise; export {};