Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron/Javascript: Detect when window is un/maximized

I am creating an electron application with a custom window bar in place of the default Windows one. I need to know when the window is maximized or un-maximized in order to change the icon on the window bar to reflect the window's state.

like image 724
Settings Menu Hard to Find Avatar asked Jun 11 '18 02:06

Settings Menu Hard to Find


2 Answers

maximize / unmaximized event is availble for browserwindow. https://github.com/electron/electron/blob/master/docs/api/browser-window.md#event-maximize

like image 197
OJ Kwon Avatar answered Nov 06 '22 14:11

OJ Kwon


you can use:

const { remote } = require("electron");
var win = remote.BrowserWindow.getFocusedWindow();
if(win.isFullScreen()) {
  // your code here
}

or :

const { remote } = require("electron");
var win = remote.BrowserWindow.getFocusedWindow();
if(win.isMaximized()) {
  // your code here
}
like image 5
Amine Beihaqi Avatar answered Nov 06 '22 15:11

Amine Beihaqi