diff --git a/atom.gyp b/atom.gyp index eef5641357c1..5b366f69f4d0 100644 --- a/atom.gyp +++ b/atom.gyp @@ -13,6 +13,7 @@ 'browser/api/lib/atom_delegate.coffee', 'browser/api/lib/dialog.coffee', 'browser/api/lib/ipc.coffee', + 'browser/api/lib/menu.coffee', 'browser/api/lib/window.coffee', 'browser/atom/atom.coffee', 'browser/atom/objects_registry.coffee', diff --git a/browser/api/lib/menu.coffee b/browser/api/lib/menu.coffee new file mode 100644 index 000000000000..0fadb0bb92dd --- /dev/null +++ b/browser/api/lib/menu.coffee @@ -0,0 +1,19 @@ +EventEmitter = require('events').EventEmitter +Window = require 'window' + +Menu = process.atomBinding('menu').Menu +Menu::__proto__ = EventEmitter.prototype + +popup = Menu::popup +Menu::popup = (window) -> + throw new TypeError('Invalid window') unless window?.constructor is Window + + popup.call this, window + +Menu::appendItem = (args...) -> @insertItem -1, args... +Menu::appendCheckItem = (args...) -> @insertCheckItem -1, args... +Menu::appendRadioItem = (args...) -> @insertRadioItem -1, args... +Menu::appendSeparator = (args...) -> @insertSeparator -1, args... +Menu::appendSubMenu = (args...) -> @insertSubMenu -1, args... + +module.exports = Menu