1.Step
mainWindow = new BrowserWindow({
width: 1200,
height: 700,
center: true,
'min-height': 700,
'min-width': 1200,
webPreferences: {nodeIntegration:true}});
mainWindow.loadURL(HOME_URL);
2.Step (some event occur and i want to temporary hide main window and show another(createFacebookWindow() fn is already loadingURL))
mainWindow.hide();
facebookWindow = require('./modules/auth/views.js').createFacebookWindow();
FB Window settings ({
width: 1200,
height: 700,
center: true,
'min-height': 700,
'min-width': 1200,
webPreferences: {nodeIntegration:false}})
3.Step (another event occur i destroy fb window and show main window)
facebookWindow.close();
facebookWindow.on('closed', function() {
facebookWindow = null;
mainWindow.show();
//I tried below options it doesn't work
//mainWindow.setSize(1200, 700);
//mainWindow.setMinimumSize(1200, 700);
Summary:
So actually after these steps, when I show mainWindow back it doesn't remember mainWindow settings min-height and min-width are not working.
When facebookWindow is not opened, all is fine, so something must happening during switching with windows. Maybe something is done in wrong order ?
You can read the BrowserWindow
documentation here: https://github.com/electron/electron/blob/master/docs/api/browser-window.md
maxWidth
instead max-width
minWidth
instead min-width
maxHeight
instead max-height
minHeight
instead min-height
you can add minWidth:500 inside the BrowserWindow while initializing window. like
function createWindow () {
// Create the browser window.
const win = new BrowserWindow({
backgroundColor: '#ffffff',
width: 1024,
height: 768,
minWidth:500,
webPreferences: {
nodeIntegration: true
}
})
note: the function (createWindow) is in main.js file so you just add minWidth:value, inside the function.
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