Electron - How to detect maximize event?

Viewed 58

I want to change maximize icon when the window is maximized.

How can i detect when the window maximized by double click on the title bar or by moving the window top of the screen.

Without running isMaximized() constantly.

1 Answers

You can listen to the maximize or the enter-full-screen event on your current window. The difference is that maximize is called when window is maximized but the enter-full-screen is called when the user maximized the window. You can read more about these events here

mainWindow.on('maximize', () => {
    // do something
})

or

mainWindow.on('enter-full-screen', () => {
    // do something
})
Related