Resizable Window in Electron. Js

Resizable Window in Electron. Js

I am making small code editor and i want user to be able to resize window if user wants. I have main window property non resizable.
mainWindow = new BrowserWindow({width: 800, height: 600 , resizable: false}); I have button I have drop down menu :

 label: 'Screen',
    submenu:[
      {
        label:'Resizable Window',
        click(){
          mainWindow.resizable = false;
        }
      },

My code doesn't work. Please help me to fix it.

1 Answer

To change if a window is resizable you have to call mainWindow.setResizable(false) instead of .resizable = false.

And it seems that you're setting resizable to false when it's already false, I think you want to set it to true to enable resizing.

In summary you would end up with something like:

label: 'Screen',
submenu: [
  {
    label: 'Resizable Window',
    click () {
      mainWindow.setResizable(true);
    }
  },
],

.setResizable Docs.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.