My electron app defines the BrowserWindow
mainWindow in the main.js. It loads an html and eventually inside of the html a script runs the function dialog.showMessageBox()
which displays a simple warning:
dialog.showMessageBox({
type: 'warning',
message: "You have been warned.",
buttons: ["OK"]
});
I want this dialog to be a child of the mainWindow b/c that makes it a modal, which disables the mainWindow until it is closed. To implement this you normally would just add mainWindow,
before the type declaration. Unfortunately it doesn't know the variable mainWindow since the dialog.showMessageBox()
is created in a different script (site.js).
How can I create a dialog, that is a child of the mainWindow without creating it in the main.js? Can ipc help somehow?