electron#ContextMenuParams TypeScript Examples

The following examples show how to use electron#ContextMenuParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: shouldShowMenu.ts    From yana with MIT License 6 votes vote down vote up
shouldShowMenu = (params: ContextMenuParams) => {
  return (
    params.editFlags.canCopy ||
    params.editFlags.canCut ||
    params.editFlags.canDelete ||
    params.editFlags.canPaste ||
    params.misspelledWord ||
    params.linkURL
  );
}
Example #2
Source File: index.ts    From TidGi-Desktop with Mozilla Public License 2.0 6 votes vote down vote up
/** Register `on('context-menu', openContextMenuForWindow)` for a window, return an unregister function */
  public async initContextMenuForWindowWebContents(webContents: WebContents): Promise<() => void> {
    const openContextMenuForWindow = async (event: Electron.Event, parameters: ContextMenuParams): Promise<void> =>
      await this.buildContextMenuAndPopup([], parameters, webContents);
    webContents.on('context-menu', openContextMenuForWindow);

    return () => {
      if (webContents.isDestroyed()) {
        return;
      }

      webContents.removeListener('context-menu', openContextMenuForWindow);
    };
  }