Handle multiple modal windows correctly
This commit is contained in:
parent
3f34f80433
commit
1104dded24
4 changed files with 59 additions and 28 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue