user441521
user441521

Reputation: 6998

node-webkit window menu not showing up

I have the following file in node-webkit but no window menu is showing up. I do get the alert I have in there so it's running the code. I'm using win 7. Any ideas?

<!DOCTYPE html>
<html>
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    We are using node.js <script>document.write(process.version)</script>.

    <script>
    var nw = require('nw.gui');

    var windowMenu = new nw.Menu({ 
        type: 'menubar' 
    });

    nw.Window.get().menu = windowMenu;

    var helpMenu = new nw.Menu();
    windowMenu.append(new nw.MenuItem({
        label: 'Help',
        submenu: helpMenu
    }));

    alert("test 2");
</script>
  </body>
</html>

Upvotes: 1

Views: 425

Answers (1)

Jonathan Dodd
Jonathan Dodd

Reputation: 176

At the time you add the menu to the current window (nw.Window.get().menu = windowMenu;) ... the menu is empty (blank). Move this line below the code which adds a menuitem -- for example, place this line at the point where your current code has the "alert" -- and the menu will be non-empty (and visible).

Upvotes: 3

Related Questions