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

History
Version(s)Changes
None
API ADDED

在 macOS 上创建共享菜单。

进程:主进程

🌐 Process: Main

warning

Electron 内置的类不能在用户代码中被继承。 欲了解更多信息,请参见 常见问题

new ShareMenu(sharingItem)

  • sharingItem 共享项 - 要共享的项目。

创建新的共享菜单。

🌐 Creates a new share menu.

实例方法

🌐 Instance Methods

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

🌐 The shareMenu object has the following instance methods:

shareMenu.popup([options])

  • options 弹出选项(可选)
    • browserWindow 浏览器窗口(可选)- 默认是当前聚焦的窗口。
    • x 数字(可选)- 默认是当前鼠标光标位置。如果声明了 y,必须声明它。
    • y 数字(可选)- 默认是当前鼠标光标位置。如果声明了 x,必须声明它。
    • positioningItem 数字(可选)macOS - 要在指定坐标下放置鼠标光标的菜单项索引。默认值为 -1。
    • callback 函数(可选)- 在菜单关闭时调用。

BrowserWindow 中以上下文菜单的形式弹出此菜单。

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

shareMenu.closePopup([browserWindow])

  • browserWindow 浏览器窗口(可选)- 默认是当前聚焦的窗口。

关闭 browserWindow 中的上下文菜单。

🌐 Closes the context menu in the browserWindow.