A Sync prompt that kinda copies the original prompt behavior for electronjs (untested outside of my laptop)
npm install electronjs-promptjs
const {Prompt} = require("electronjs-prompt");
`Then call the constructor (there's no personalisations yet for the windows and design)
`js
async function loadMainWindow() {
win = new BrowserWindow({
width: 800, height: 600, show: false, webPreferences: {
preload: path.join(__dirname, 'preload.js'), nodeIntegration: true, contextIsolation: false
}, autoHideMenuBar: true
}) win.loadURL(
file://${app.getAppPath()}/public/index.html?app_path=${app.getAppPath()}).then(r => {
win.show();
}); win.webContents.on('did-finish-load', () => {
win.maximize();
});
new Prompt(ipcMain);
}
`You can then call prompt from your renderer using
`js
return ipcRenderer.sendSync('prompt', msg);
`
It now also works with confirm and sends back an integer (0 | 1)
`js
return ipcRenderer.sendSync('confirm', msg);
``