Read menu item's properties in menu's delegate.

This commit is contained in:
Cheng Zhao 2013-05-16 20:06:25 +08:00
parent 84e721188b
commit 4984f30e48
3 changed files with 16 additions and 10 deletions

View file

@ -4,15 +4,18 @@ class MenuItem
@types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
constructor: (options) ->
{@type, @label, @sublabel, @click, @checked, @groupId, @submenu} = options
{click, @type, @label, @sublabel, @accelerator, @enabled, @visible, @checked, @groupId, @submenu} = options
@type = @type ? 'normal'
@label = @label ? ''
@sublabel = @sublabel ? ''
@enabled = @enabled ? true
@visible = @visible ? true
throw new Error('Unknown menu type') if MenuItem.types.indexOf(@type) is -1
throw new Error('Invalid menu') if @type is 'submenu' and @submenu?.constructor.name isnt 'Menu'
@commandId = ++nextCommandId
@click = -> click() if typeof click is 'function'
module.exports = MenuItem