Search code examples
google-chromenode-webkit

gui.Window.open() returns undefined


I have a NW application that starts with a splash screen, which then opens the main application in a new window. The code is approximately this:

var appWin = gui.Window.open("https://localhost:8080/", {
    "icon": "app_icon.png",
    "frame": true,
    "width": 1200,
    "height": 800,
    "position": "center",
    "resizable": true,
    "min_width": 400,
    "min_height": 200
 })

 appWin.on('loaded', function() {
    // hide the splash screen
 })

However, appWin is always undefined, even though the new window opens and displays the correct content.

I'm using nw-builder version 0.13.4, but I have also tried various versions of 0.14.x, 0.15.x and 0.16.x, with the same problem.

Any suggestions of viable workarounds would also be acceptable.


Solution

  • // Open a new window.
    nw.Window.open("https://localhost:8080/", {
        "icon": "app_icon.png",
        "frame": true,
        "width": 1200,
        "height": 800,
        "position": "center",
        "resizable": true,
        "min_width": 400,
        "min_height": 200
     }, function(win) {
           console.log('window opened'. win);
           win.on('loaded', function() {
                console.log('window created');
           }
    });