/** * Methods for interacting with a ToDesktop application's tray icon. * * @remarks * This package exposes a number of methods for interacting with a ToDesktop * application's tray icon. * * The tray icon is a part of the operating systems UI, located: * * - at the right of the Menu Bar on macOS; * - in the System Tray on Windows. * * @experimental * @public * @packageDocumentation */ import { DisplayBalloonOptions, Point } 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 Tray. * * @param options - Tray constructor options. * @returns Identifier for the newly created Tray. * @public */ export declare function create(...args: [image: string | InstanceRefObject, guid?: string | undefined]): Promise; /** * Set the title of the app's tray item. * * @param options - ref: Reference for the Tray; title: title for the tray. * @public */ export declare function setTitle(title: string): Promise; export declare function setTitle(options: SetTitleOptions): Promise; interface SetTitleOptions { ref: Ref; title: string; } /** * Remove the app's tray item. * * @param options - ref: Reference for the Tray; * @public */ export declare function destroy(): Promise; export declare function destroy(options: { ref: Ref; }): Promise; interface SetTitleOptions { ref: Ref; title: string; } /** * Sets the image associated with this tray icon. * * @param options - ref: Reference for the Tray. * @public */ export declare function setImage({ ref, image, }: { ref: Ref; image: string | InstanceRefObject; }): Promise; /** * Sets the image associated with this tray icon when pressed on macOS. * * @param options - ref: Reference for the Tray. * @public */ export declare function setPressedImage({ ref, image, }: { ref: Ref; image: string | InstanceRefObject; }): Promise; /** * Sets the hover text for this tray icon. * * @param options - ref: Reference for the Tray; tooltip: hover text to display. * @public */ export declare function setToolTip({ ref, tooltip, }: { ref: Ref; tooltip: string; }): Promise; /** * Gets the title displayed next to the tray icon in the status bar. * * @param options - ref: Reference for the Tray. * @public */ export declare function getTitle({ ref }: { ref: Ref; }): Promise; /** * Sets the option to ignore double click events. Ignoring these events allows you to detect every individual click of the tray icon. * * @param options - ref: Reference for the Tray; ignore: whether to ignore double clicks or not; * @public */ export declare function setIgnoreDoubleClickEvents({ ref, ignore, }: { ref: Ref; ignore: boolean; }): Promise; /** * Whether double click events will be ignored. * * @param options - ref: Reference for the Tray. * @public */ export declare function getIgnoreDoubleClickEvents({ ref }: { ref: Ref; }): Promise; /** * Displays a tray balloon on windows. * * @param options - ref: Reference for the Tray. * @public */ export declare function displayBalloon({ ref, ...options }: { ref: Ref; } & DisplayBalloonOptions): Promise; /** * Removes a tray balloon. * * @param options - ref: Reference for the Tray. * @public */ export declare function removeBalloon({ ref }: { ref: Ref; }): Promise; /** * Returns focus to the taskbar notification area. Windows only. * * @param options - ref: Reference for the Tray. * @public */ export declare function focus({ ref }: { ref: Ref; }): Promise; /** * Pops up the context menu of the tray icon. When menu is passed, the menu will be shown instead of the tray icon's context menu. MacOS and Windows only. * * @param options - ref: Reference for the Tray; menu: Reference for the Menu; position: x and y coordinates. * @public */ export declare function popUpContextMenu({ ref, ...options }: { ref: Ref; menu?: InstanceRefObject | undefined; position?: Electron.Point | undefined; }): Promise; /** * Closes an open context menu, as set by tray.setContextMenu(). MacOS and Windows only. * * @param options - ref: Reference for the Tray. * @public */ export declare function closeContextMenu({ ref }: { ref: Ref; }): Promise; /** * Sets the context menu for this icon. * * @param options - ref: Reference for the Tray; menu: Reference for the Menu; * @public */ export declare function setContextMenu({ ref, ...options }: { ref: Ref; menu?: InstanceRefObject | undefined; }): Promise; /** * The bounds of this tray icon as Object. MacOS and Windows only. * * @param options - ref: Reference for the Tray. * @public */ export declare function getBounds({ ref }: { ref: Ref; }): Promise; /** * Whether the tray icon is destroyed. * * @param options - ref: Reference for the Tray. * @public */ export declare function isDestroyed({ ref }: { ref: Ref; }): Promise; /** * @public */ export declare type TrayEvents = NamespaceEvents<{ "balloon-click": () => void; "balloon-closed": () => void; "balloon-show": () => void; click: () => void; "double-click": () => void; "drag-end": () => void; "drag-enter": () => void; "drag-leave": () => void; drop: () => void; "drop-files": (files: string[]) => void; "drop-text": (text: string) => void; "mouse-down": (position: Point) => void; "mouse-enter": (position: Point) => void; "mouse-leave": (position: Point) => void; "mouse-move": (position: Point) => void; "mouse-up": (position: Point) => void; "right-click": () => void; }>; /** * Subcribes to an event on a tray 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 Tray. * @returns unsubscribe callback. * @public */ export declare const on: (eventName: E, callback: NamespaceEvents<{ "balloon-click": () => void; "balloon-closed": () => void; "balloon-show": () => void; click: () => void; "double-click": () => void; "drag-end": () => void; "drag-enter": () => void; "drag-leave": () => void; drop: () => void; "drop-files": (files: string[]) => void; "drop-text": (text: string) => void; "mouse-down": (position: Point) => void; "mouse-enter": (position: Point) => void; "mouse-leave": (position: Point) => void; "mouse-move": (position: Point) => void; "mouse-up": (position: Point) => void; "right-click": () => void; }>[E], args_0: { ref: InstanceRefObject; preventDefault?: boolean; }) => Promise<() => Promise>; /** * Unsubscribes all tray objects from the event name. * * @param options - ref: Reference for the Tray; eventName: The event name to unsubscribe from; * @returns Reference for the tray. * @public */ export declare const removeAllListeners: (eventName: E, args_0: { ref: InstanceRefObject; }) => Promise; export {};