Fix browserWindow detection in menu.popup()
This commit is contained in:
parent
21de806c80
commit
5a25b88b50
2 changed files with 12 additions and 17 deletions
|
@ -53,15 +53,14 @@ Menu.prototype.popup = function (options) {
|
|||
if (typeof x !== 'number') x = -1
|
||||
if (typeof y !== 'number') y = -1
|
||||
if (typeof positioningItem !== 'number') positioningItem = -1
|
||||
if (!window || (window && window.constructor !== BrowserWindow)) {
|
||||
window = BrowserWindow.getFocusedWindow()
|
||||
|
||||
// No window focused?
|
||||
if (!window) {
|
||||
const wins = BrowserWindow.getAllWindows()
|
||||
if (wins && wins.length > 0) {
|
||||
window = wins[0]
|
||||
} else {
|
||||
// find which window to use
|
||||
const wins = BrowserWindow.getAllWindows()
|
||||
if (!wins || wins.indexOf(window) === -1) {
|
||||
window = BrowserWindow.getFocusedWindow()
|
||||
if (!window && wins && wins.length > 0) {
|
||||
window = wins[0]
|
||||
if (!window) {
|
||||
throw new Error(`Cannot open Menu without a BrowserWindow present`)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue