win: Force menuWillShow to be called when setting window menu.
This commit is contained in:
parent
0e5f697b48
commit
6ee437e9bf
2 changed files with 11 additions and 7 deletions
|
@ -230,7 +230,7 @@ void Menu::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("isEnabledAt", &Menu::IsEnabledAt)
|
||||
.SetMethod("isVisibleAt", &Menu::IsVisibleAt)
|
||||
#if defined(OS_WIN) || defined(TOOLKIT_GTK)
|
||||
.SetMethod("attachToWindow", &Menu::AttachToWindow)
|
||||
.SetMethod("_attachToWindow", &Menu::AttachToWindow)
|
||||
#endif
|
||||
.SetMethod("_popup", &Menu::Popup);
|
||||
}
|
||||
|
|
|
@ -91,18 +91,22 @@ Menu::insert = (pos, item) ->
|
|||
@items.splice pos, 0, item
|
||||
@commandsMap[item.commandId] = item
|
||||
|
||||
Menu::attachToWindow = (window) ->
|
||||
@_callMenuWillShow() if process.platform is 'win32'
|
||||
@_attachToWindow window
|
||||
|
||||
# Force menuWillShow to be called
|
||||
Menu::_callMenuWillShow = ->
|
||||
@delegate?.menuWillShow()
|
||||
item.submenu._callMenuWillShow() for item in @items when item.submenu?
|
||||
|
||||
applicationMenu = null
|
||||
Menu.setApplicationMenu = (menu) ->
|
||||
throw new TypeError('Invalid menu') unless menu?.constructor is Menu
|
||||
applicationMenu = menu # Keep a reference.
|
||||
|
||||
if process.platform is 'darwin'
|
||||
# Force menuWillShow to be called
|
||||
menuWillShow = (menu) ->
|
||||
menu.delegate?.menuWillShow()
|
||||
menuWillShow item.submenu for item in menu.items when item.submenu?
|
||||
menuWillShow menu
|
||||
|
||||
menu._callMenuWillShow()
|
||||
bindings.setApplicationMenu menu
|
||||
else
|
||||
windows = BrowserWindow.getAllWindows()
|
||||
|
|
Loading…
Reference in a new issue