Add async option to menu.popup

This commit is contained in:
Kevin Sawicki 2017-02-15 15:57:36 -08:00
parent b091d104f5
commit 4430927f98
5 changed files with 38 additions and 15 deletions

View file

@ -144,6 +144,9 @@ Menu.prototype._init = function () {
}
Menu.prototype.popup = function (window, x, y, positioningItem) {
let asyncPopup = false
// menu.popup(x, y, positioningItem)
if (typeof window !== 'object' || window.constructor !== BrowserWindow) {
// Shift.
positioningItem = y
@ -152,6 +155,15 @@ Menu.prototype.popup = function (window, x, y, positioningItem) {
window = BrowserWindow.getFocusedWindow()
}
// menu.popup(window, {})
if (typeof x === 'object') {
const options = x
x = options.x
y = options.y
positioningItem = options.positioningItem
asyncPopup = options.async
}
// Default to showing under mouse location.
if (typeof x !== 'number') x = -1
if (typeof y !== 'number') y = -1
@ -159,7 +171,7 @@ Menu.prototype.popup = function (window, x, y, positioningItem) {
// Default to not highlighting any item.
if (typeof positioningItem !== 'number') positioningItem = -1
this.popupAt(window, x, y, positioningItem)
this.popupAt(window, x, y, positioningItem, asyncPopup)
}
Menu.prototype.append = function (item) {