Skip to main content

ShareMenu

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.ShareMenu类在macOS上创建共享菜单,可用于将当前上下文中的信息共享给应用程序、社交媒体帐户和其他服务。

For including the share menu as a submenu of other menus, please use the shareMenu role of MenuItem.要将共享菜单包含为其他菜单的子菜单,请使用MenuItemshareMenu角色。

Class: ShareMenu

Create share menu on macOS.在macOS上创建共享菜单。

Process:进程:Main

new ShareMenu(sharingItem)

  • sharingItem SharingItem - The item to share.要共享的项目。

Creates a new share menu.创建一个新的共享菜单。

Instance Methods实例方法

The shareMenu object has the following instance methods:shareMenu对象具有以下实例方法:

shareMenu.popup([options])

  • options PopupOptions (optional)
    • browserWindow BrowserWindow (optional) - Default is the focused window.默认为聚焦窗口。
    • x number (optional) - Default is the current mouse cursor position. 默认值为当前鼠标游标位置。Must be declared if y is declared.如果已声明y,则必须声明。
    • y number (optional) - Default is the current mouse cursor position. 默认值为当前鼠标游标位置。Must be declared if x is declared.如果已声明x,则必须声明。
    • positioningItem number (optional) macOS - The index of the menu item to be positioned under the mouse cursor at the specified coordinates. 要定位在鼠标游标下指定坐标处的菜单项的索引。Default is -1.默认值为-1。
    • callback Function (optional) - Called when menu is closed.当菜单关闭时调用。

Pops up this menu as a context menu in the BrowserWindow.BrowserWindow中弹出此菜单作为上下文菜单。

shareMenu.closePopup([browserWindow])

  • browserWindow BrowserWindow (optional) - Default is the focused window.默认为聚焦窗口。

Closes the context menu in the browserWindow.关闭browserWindow中的上下文菜单。