From d6103dd639e8b8690b0e0dd27093eaf2044cd40b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 14 May 2013 19:24:52 +0800 Subject: [PATCH] Expose Menu API in javascript. --- atom.gyp | 1 + browser/api/lib/menu.coffee | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 browser/api/lib/menu.coffee 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