Do not init Menu lazily, otherwise empty menus would be invalid.
This commit is contained in:
parent
541b855512
commit
2f5dfb1dc7
1 changed files with 19 additions and 20 deletions
|
@ -26,18 +26,7 @@ generateGroupId = (items, pos) ->
|
||||||
Menu = bindings.Menu
|
Menu = bindings.Menu
|
||||||
Menu::__proto__ = EventEmitter.prototype
|
Menu::__proto__ = EventEmitter.prototype
|
||||||
|
|
||||||
Menu::popup = (window) ->
|
Menu::_init = ->
|
||||||
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
|
|
||||||
@_popup window
|
|
||||||
|
|
||||||
Menu::append = (item) ->
|
|
||||||
@insert @getItemCount(), item
|
|
||||||
|
|
||||||
Menu::insert = (pos, item) ->
|
|
||||||
throw new TypeError('Invalid item') unless item?.constructor is MenuItem
|
|
||||||
|
|
||||||
# Create delegate.
|
|
||||||
unless @delegate?
|
|
||||||
@commandsMap = {}
|
@commandsMap = {}
|
||||||
@groupsMap = {}
|
@groupsMap = {}
|
||||||
@items = []
|
@items = []
|
||||||
|
@ -56,6 +45,16 @@ Menu::insert = (pos, item) ->
|
||||||
break
|
break
|
||||||
v8Util.setHiddenValue group[0], 'checked', true unless checked
|
v8Util.setHiddenValue group[0], 'checked', true unless checked
|
||||||
|
|
||||||
|
Menu::popup = (window) ->
|
||||||
|
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
|
||||||
|
@_popup window
|
||||||
|
|
||||||
|
Menu::append = (item) ->
|
||||||
|
@insert @getItemCount(), item
|
||||||
|
|
||||||
|
Menu::insert = (pos, item) ->
|
||||||
|
throw new TypeError('Invalid item') unless item?.constructor is MenuItem
|
||||||
|
|
||||||
switch item.type
|
switch item.type
|
||||||
when 'normal' then @insertItem pos, item.commandId, item.label
|
when 'normal' then @insertItem pos, item.commandId, item.label
|
||||||
when 'checkbox' then @insertCheckItem pos, item.commandId, item.label
|
when 'checkbox' then @insertCheckItem pos, item.commandId, item.label
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue