electronjs-prompt
v1.0.2
Published
A Sync prompt that kinda copies the original prompt behavior for electronjs (untested outside of my laptop)
Downloads
8
Readme
_prompt
A Sync prompt that kinda copies the original prompt behavior for electronjs (untested outside of my laptop)
How to use
Simply require it in main.js
const {Prompt} = require("electronjs-prompt");
Then call the constructor (there's no personalisations yet for the windows and design)
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
return ipcRenderer.sendSync('prompt', msg);
It now also works with confirm and sends back an integer (0 | 1)
return ipcRenderer.sendSync('confirm', msg);