Build node-webkit style Menu API arounding the delegate-style Menu API.
This commit is contained in:
parent
faf7280d1f
commit
84e721188b
4 changed files with 38 additions and 12 deletions
18
browser/api/lib/menu_item.coffee
Normal file
18
browser/api/lib/menu_item.coffee
Normal file
|
@ -0,0 +1,18 @@
|
|||
nextCommandId = 0
|
||||
|
||||
class MenuItem
|
||||
@types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
|
||||
|
||||
constructor: (options) ->
|
||||
{@type, @label, @sublabel, @click, @checked, @groupId, @submenu} = options
|
||||
|
||||
@type = @type ? 'normal'
|
||||
@label = @label ? ''
|
||||
@sublabel = @sublabel ? ''
|
||||
|
||||
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
|
||||
|
||||
module.exports = MenuItem
|
Loading…
Add table
Add a link
Reference in a new issue