Handle multiple modal windows correctly

This commit is contained in:
Cheng Zhao 2016-06-18 09:42:18 +09:00
parent 3f34f80433
commit 1104dded24
4 changed files with 59 additions and 28 deletions

View file

@ -97,23 +97,6 @@ BrowserWindow.prototype._init = function () {
})
}
BrowserWindow.prototype.setModal = function (modal) {
const parent = this.getParentWindow()
if (!parent) {
throw new Error('setModal can only be called for child window')
}
let closeListener = () => parent.enable()
if (modal) {
parent.disable()
this.once('closed', closeListener)
this.show()
} else {
parent.enable()
this.removeListener('closed', closeListener)
}
}
BrowserWindow.getFocusedWindow = () => {
for (let window of BrowserWindow.getAllWindows()) {
if (window.isFocused()) return window