Reputation: 53
Is there a way to show the dialog from dialog.showMessageBox() on top of everything?
For example, I'm woking on the notepad and given some event in my Electron application it will open a dialog that should now be the main window for the user to see.
Upvotes: 5
Views: 4164
Reputation: 2830
For many use cases, the correct approach will be to pass the existing main window to showMessageBox
:
dialog.showMessageBox(mainWindow, dialogOpts)
This will make the message box a modal of the main window. The user will need to close the modal before being able to continue using the main window.
Upvotes: 0
Reputation: 21
const { remote } = require("electron")
dialog.showMessageBox(**remote.getCurrentWindow()**, [options])
Set the first parameter
Upvotes: 2
Reputation: 5531
It's kinda ugly but you can pass a dummy holder browserwindow which is always on top.
dialog.showMessageBox(
new BrowserWindow({
show: false,
alwaysOnTop: true
}),
{
type: 'question',
message: 'is on top'
}
)
Upvotes: 6