question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Window event "unmaximize" not triggered upon unmaximize.

See original GitHub issue

Specs:

  • Windows 10
  • NW.JS 0.14.4 SDK

I’m using frameless Window, so I have to create my own window buttons. My app is for Windows OS only and below is my implementation of the idea.

$(".win-max-btn").click(function() {
    if (!win.isMaximized)
        win.maximize();
    else
        win.unmaximize();
});
win.on("maximize", function(){
    $(".win-max-btn").find("i").attr("class", "ws ws-restore"); //change the button's icon
    win.isMaximized = true;
});
win.on("unmaximize", function(){
    $(".win-max-btn").find("i").attr("class", "ws ws-maximize"); //change the button's icon
    win.isMaximized = false;
});

The problem is The button is changed to the “restore” icon when maximized and win.isMaximized is set to true, but when I unmaximize the window through mean of clicking the button or dragging the “window frame area” down, the window is unmaximized but the icon isn’t changed because the event unmaximize was never triggered.

I have tested with the event restore is it did work and was triggered when the window was unmaximized but that isn’t what I want.

So if I read the docs right, the event unmaximize might be bugged?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rogerwangcommented, May 11, 2016

There is an error in the document, we’ll fix it soon.

1reaction
iteufelcommented, May 10, 2016

NWjs has no isMaximized you must use chrome.app.window.current().isMaximized()

Use restore instead of unmaximize

unmaximize and leave-fullscreen events of Window object is deprecated and replaced by restore. When window is restored from minimized, maximized or fullscreen, restore event is triggered instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

electron win.unmaximize(); not working - Stack Overflow
Instead of unmaximize use restore as below, it will work. $('#maximize').click(function() { if(win.isMaximized()){ win.restore(); }else{ ...
Read more >
Window - NW.js Documentation
Restore window to previous state after the window is minimized, i.e. the reverse of minimize() . It's not named unminimize since restore is...
Read more >
Window: beforeunload event - Web APIs | MDN
The beforeunload event is fired when the window, the document and its resources are about ... so as to minimize the effect on...
Read more >
Unexplained Windows or software behavior may be caused ...
Components of Windows or other programs no longer work. ... You can use the restore point to restore to the computer configuration that...
Read more >
app | Electron
Note: On Windows, this event will not be emitted if the app is closed due to a ... Various actions can trigger this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found