目录

ShowContextMenuParams

Parameters for showing a context menu.

import { ShowContextMenuParams } from '@mobrowser/api';

Example 

import {
  app,
  desktop,
  ContextMenu,
  ContextMenuItem,
  ShowContextMenuParams
} from '@mobrowser/api';

const win = app.createWindow()
win.browser.handle('showContextMenu', (params: ShowContextMenuParams) => {
  if (params.contentType === 'link') {
    return new ContextMenu({
      items: [
        new ContextMenuItem({
          label: `Open ${params.linkText}`,
          action: (item: ContextMenuItem) => {
            desktop.openUrl(params.linkUrl)
          }
        }),
        'copy'
      ]
    })
  }
  return 'suppress'
})

Properties 

location 

readonly location: Point;

The location of the context menu related to the browser.

linkUrl 

readonly linkUrl: string;

The URL of the link that the context menu is being shown for.

linkText 

readonly linkText: string;

The text of the link that the context menu is being shown for.

srcUrl 

readonly srcUrl: string;

The URL of the source of the HTML element that the context menu is being shown for.

pageUrl 

readonly pageUrl: string;

The URL of the top-level page that the context menu is being shown for.

frameUrl 

readonly frameUrl: string;

The URL of the sub-frame that the context menu is being shown for.

isSubFrame 

readonly isSubFrame: boolean;

Whether the context menu is being shown for a sub-frame.

selectedText 

readonly selectedText: string;

The selected text that the context menu is being shown for.

contentType 

readonly contentType: ContextMenuContentType;

The type of the content that the context menu is being shown for.