2013-05-14 11:24:52 +00:00
|
|
|
EventEmitter = require('events').EventEmitter
|
2013-05-15 11:19:35 +00:00
|
|
|
BrowserWindow = require 'browser_window'
|
2013-05-14 11:24:52 +00:00
|
|
|
|
|
|
|
Menu = process.atomBinding('menu').Menu
|
|
|
|
Menu::__proto__ = EventEmitter.prototype
|
|
|
|
|
|
|
|
popup = Menu::popup
|
|
|
|
Menu::popup = (window) ->
|
2013-05-15 11:19:35 +00:00
|
|
|
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
|
2013-05-14 11:24:52 +00:00
|
|
|
|
|
|
|
popup.call this, window
|
|
|
|
|
2013-05-14 14:17:25 +00:00
|
|
|
insertSubMenu = Menu::insertSubMenu
|
|
|
|
Menu::insertSubMenu = (index, command_id, label, submenu) ->
|
|
|
|
throw new TypeError('Invalid menu') unless submenu?.constructor is Menu
|
|
|
|
|
|
|
|
@menus = [] unless Array.isArray @menus
|
|
|
|
@menus.push submenu # prevent submenu from getting destroyed
|
|
|
|
insertSubMenu.apply this, arguments
|
|
|
|
|
2013-05-14 11:24:52 +00:00
|
|
|
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
|