Skip to main content

ShareMenu

ShareMenu 类在 macOS 上创建 分享菜单,可用于将当前上下文中的信息共享到应用、社交媒体账户和其他服务。

¥The ShareMenu class creates Share Menu on macOS, which can be used to share information from the current context to apps, social media accounts, and other services.

要将共享菜单包含为其他菜单的子菜单,请使用 MenuItemshareMenu 角色。

¥For including the share menu as a submenu of other menus, please use the shareMenu role of MenuItem.

类:ShareMenu

¥Class: ShareMenu

在 macOS 上创建共享菜单。

¥Create share menu on macOS.

进程:主进程

¥Process: Main

new ShareMenu(sharingItem)

  • sharingItem SharingItem - 要分享的项目。

    ¥sharingItem SharingItem - The item to share.

创建新的共享菜单。

¥Creates a new share menu.

实例方法

¥Instance Methods

shareMenu 对象具有以下实例方法:

¥The shareMenu object has the following instance methods:

shareMenu.popup([options])

  • options 弹出选项(可选)

    ¥options PopupOptions (optional)

    • browserWindow BrowserWindow(可选) - 默认是聚焦窗口。

      ¥browserWindow BrowserWindow (optional) - Default is the focused window.

    • x 号码(可选) - 默认为当前鼠标光标位置。如果声明了 y,则必须声明。

      ¥x number (optional) - Default is the current mouse cursor position. Must be declared if y is declared.

    • y 号码(可选) - 默认为当前鼠标光标位置。如果声明了 x,则必须声明。

      ¥y number (optional) - Default is the current mouse cursor position. Must be declared if x is declared.

    • positioningItem 数字(可选)macOS - 要定位在鼠标光标下方指定坐标处的菜单项的索引。默认值为-1。

      ¥positioningItem number (optional) macOS - The index of the menu item to be positioned under the mouse cursor at the specified coordinates. Default is -1.

    • callback 功能(可选) - 菜单关闭时调用。

      ¥callback Function (optional) - Called when menu is closed.

弹出此菜单作为 BrowserWindow 中的上下文菜单。

¥Pops up this menu as a context menu in the BrowserWindow.

shareMenu.closePopup([browserWindow])

  • browserWindow BrowserWindow(可选) - 默认是聚焦窗口。

    ¥browserWindow BrowserWindow (optional) - Default is the focused window.

关闭 browserWindow 中的上下文菜单。

¥Closes the context menu in the browserWindow.