user9078405
user9078405

Reputation:

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.

Upvotes: 9

Views: 21193

Answers (1)

Joshua
Joshua

Reputation: 5322

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.

Upvotes: 12

Related Questions