Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Menu Creation #1870

Closed
gitchs opened this issue May 16, 2014 · 5 comments
Closed

Windows Menu Creation #1870

gitchs opened this issue May 16, 2014 · 5 comments
Labels

Comments

@gitchs
Copy link
Contributor

gitchs commented May 16, 2014

I append a menu shortcut test case in my repo. It works well on Linux and OSX.
But on Windows platform, the case does not work well, but if I move codes in line 22, line 24 and line 19 to the end of the script, it works.

I think the menu should could be create and append at any place but not with a specific order. Since there is a workaround method , I will continue my porting work first.
@rogerwang Should I look back later and fix it(I think it is a bug.)?

Here is the workaround code. The only difference is the last 3 line JavaScript codes' position


        var gui = require('nw.gui');
        var win = gui.Window.get();
        var menubar = new gui.Menu({ type: 'menubar' });

        var menubar_file = new gui.MenuItem({"label":"File"});
        var file_menu = new gui.Menu();
        var file_quit_item = new gui.MenuItem({
          "label":"Quit",
          "click":function(){
            gui.App.quit();
          },
          "key":"q",
          "modifiers":"ctrl"
        });
        var file_info_item = new gui.MenuItem({
          "label":"Info",
          "click":function(){
            console.log("hello world");
          },
          "key":"i",
          "modifiers":"ctrl+alt"
        });
        file_menu.append(file_info_item);
        file_menu.append(file_quit_item);

        var file_about_item = new gui.MenuItem({
          "label":"About us!",
          "key":"U",
          "modifiers":"ctrl",
          "click":function(){
            console.log("About Info");
          }
        });
        file_menu.insert(file_about_item,0);
        menubar_file.submenu = file_menu;
        menubar.append(menubar_file);
        win.menu = menubar;  

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@jmdobry
Copy link

jmdobry commented Jul 15, 2014

I've noticed that in order for my menus to work on windows I have to build them in the opposite order that I build them for Mac.

@felicienfrancois
Copy link

The workaround code does not work for me.
Hotkeys are not displayed in the menu.

Node-webkit 0.10.5 - Windows 8.1

@tshinnic
Copy link

I believe it is the case that all the 'instructions' - what the menu contains and how it is to be displayed - must be setup in the object data structures before you do the win.menu = menubar; action. It seems like setting win.menu must be the last thing you do. Any further changes to the data structures are not noticed by the nwjs code. For sure when I start moving the win.menu = ... around, then nwjs 'sees' fewer and fewer menu items!

And yes I'm testing on Windows and haven't tried Linux yet. Whether the Windows implementation has stricter requirements would be a useful thing for Roger or someone else to comment on.

@mnemanja
Copy link

I had this issue, and applying the @tshinnic's approach solved the menu item not showing, or additional changes to it not being applied. So on a build nwjs-v0.12.3-win-x64 the win.menu = ...; has to be the last line after that block's changes.

@stale
Copy link

stale bot commented Oct 24, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 24, 2017
@stale stale bot closed this as completed Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants