nwutils / nw-sample-apps

Sample Apps
MIT License
1.95k stars 551 forks source link

Custom Tray Menu doesnt work on MacOSX #39

Open TheAifam5 opened 8 years ago

TheAifam5 commented 8 years ago

NW.JS Version: v0.15.4 NW.JS Commit hash: 63bc85a-0fc8753-3ee2c58-8655cb9

/Users/theaifam5/Desktop/Test/custom-tray-menu/custom_tray_menu.js:3
var gui = global.window.nwDispatcher.requireNwGui();
                                    ^
TypeError: Cannot read property 'requireNwGui' of undefined
    at Object.<anonymous> (/Users/theaifam5/Desktop/Test/custom-tray-menu/custom_tray_menu.js:3:37)
    at Module._compile (module.js:565:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:482:32)
    at tryModuleLoad (module.js:441:12)
    at Function.Module._load (module.js:433:3)
    at Module.require (module.js:492:17)
    at require (internal/module.js:20:19)
    at self.require (<anonymous>:11:26)

Buttons also doesn't work.

joeblew99 commented 8 years ago

I just tried this and got the same error.

i was following the tutorial here: https://github.com/nwjs/npm-installer

x-MacBook-Pro:nw-sample-apps apple$ "node_modules/.bin/nw" custom-tray-menu

/Users/apple/workspace/go/src/bitbucket.org/gedw99/md/try/nwjs/nw-sample-apps/custom-tray-menu/custom_tray_menu.js:3
var gui = global.window.nwDispatcher.requireNwGui();
                                    ^
TypeError: Cannot read property 'requireNwGui' of undefined
    at Object.<anonymous> (/Users/apple/workspace/go/src/bitbucket.org/gedw99/md/try/nwjs/nw-sample-apps/custom-tray-menu/custom_tray_menu.js:3:37)
    at Module._compile (module.js:565:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:482:32)
    at tryModuleLoad (module.js:441:12)
    at Function.Module._load (module.js:433:3)
    at Module.require (module.js:492:17)
    at require (internal/module.js:20:19)
    at self.require (<anonymous>:11:26)
joshplant commented 7 years ago

I've created a new Tray Menu app example, which should solve this problem. I was having similar problems on Windows and Ubuntu, and those problems are fixed with my version. Please see PR #41.