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.
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.
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'
}
)
const { remote } = require("electron")
dialog.showMessageBox(**remote.getCurrentWindow()**, [options])
Set the first parameter
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.