I am trying to create two windows from the main process. The second window should always be shown on top of the first window. On the Electron website I have read that I have to create a parent and a child window to do this. This is my code:
let win;
let child;
function createWindow(){
// Create the browser window.
win = new BrowserWindow({width: 1024, height: 768, show: false});
child = new BrowserWindow({parent: win});
child.show();
win.once('ready-to-show', () => {
win.show()
})
// and load the index.html of the app.
win.loadURL(`file://${__dirname}/index.html`);
// Emitted when the window is closed.
win.on('closed', () => {
win = null;
});
}
app.on('ready', createWindow);
When I start the program it creates two windows but the child window is not always on top. When I close the parent window (win) both windows are closed. How do I make the child window always be shown on top? I'm using Fedora 24 with Gnome.
Try to use child.setAlwaysOnTop(true);
method after child-win init.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With