1. API
  2. contextMenu

API

Methods for creating and manipulating context menus in a native ToDesktop window.

Remarks

This package exposes a number of methods for creating and manipulating context menus in a native ToDesktop window.

Functions

Function Description
create(config) Creates and presents a context menu. If the user's cursor is within the bounds of the current window, the context menu will be appear at the cursor position.

create()

Creates and presents a context menu. If the user's cursor is within the bounds of the current window, the context menu will be appear at the cursor position.

Signature:

        import { contextMenu } from "@todesktop/client-core"
contextMenu.create(config: ContextMenuItem[] | ContextMenuItem): Promise<void>;

      
Parameters
Parameter Type Description
config ContextMenuItem[] | ContextMenuItem A single ContextMenuItem or array of ContextMenuItems to present.

Returns:

Promise<void>

Type Aliases

ContextMenuItem

Signature:

        export declare type ContextMenuItem = ContextMenuItemBase & (ContextMenuItemLabel | ContextMenuItemRole);

      

References: ContextMenuItemBase, ContextMenuItemLabel, ContextMenuItemRole

ContextMenuItemBase

Signature:

        export declare type ContextMenuItemBase = {
    onClick?(): void;
    type?: "normal" | "separator" | "submenu" | "checkbox" | "radio";
};

      

ContextMenuItemLabel

Signature:

        export declare type ContextMenuItemLabel = {
    label: string;
};

      

ContextMenuItemRole

Signature:

        export declare type ContextMenuItemRole = {
    role: "undo" | "redo" | "cut" | "copy" | "paste" | "pasteAndMatchStyle" | "delete" | "selectAll" | "reload" | "forceReload" | "toggleDevTools" | "resetZoom" | "zoomIn" | "zoomOut" | "togglefullscreen" | "window" | "minimize" | "close" | "help" | "about" | "services" | "hide" | "hideOthers" | "unhide" | "quit" | "startSpeaking" | "stopSpeaking" | "zoom" | "front" | "appMenu" | "fileMenu" | "editMenu" | "viewMenu" | "shareMenu" | "recentDocuments" | "toggleTabBar" | "selectNextTab" | "selectPreviousTab" | "mergeAllWindows" | "clearRecentDocuments" | "moveTabToNewWindow" | "windowMenu";
};