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("isEnabledAt", &Menu::IsEnabledAt)
|
||||||
.SetMethod("isVisibleAt", &Menu::IsVisibleAt)
|
.SetMethod("isVisibleAt", &Menu::IsVisibleAt)
|
||||||
#if defined(OS_WIN) || defined(TOOLKIT_GTK)
|
#if defined(OS_WIN) || defined(TOOLKIT_GTK)
|
||||||
.SetMethod("attachToWindow", &Menu::AttachToWindow)
|
.SetMethod("_attachToWindow", &Menu::AttachToWindow)
|
||||||
#endif
|
#endif
|
||||||
.SetMethod("_popup", &Menu::Popup);
|
.SetMethod("_popup", &Menu::Popup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,18 +91,22 @@ Menu::insert = (pos, item) ->
|
||||||
@items.splice pos, 0, item
|
@items.splice pos, 0, item
|
||||||
@commandsMap[item.commandId] = 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
|
applicationMenu = null
|
||||||
Menu.setApplicationMenu = (menu) ->
|
Menu.setApplicationMenu = (menu) ->
|
||||||
throw new TypeError('Invalid menu') unless menu?.constructor is Menu
|
throw new TypeError('Invalid menu') unless menu?.constructor is Menu
|
||||||
applicationMenu = menu # Keep a reference.
|
applicationMenu = menu # Keep a reference.
|
||||||
|
|
||||||
if process.platform is 'darwin'
|
if process.platform is 'darwin'
|
||||||
# Force menuWillShow to be called
|
menu._callMenuWillShow()
|
||||||
menuWillShow = (menu) ->
|
|
||||||
menu.delegate?.menuWillShow()
|
|
||||||
menuWillShow item.submenu for item in menu.items when item.submenu?
|
|
||||||
menuWillShow menu
|
|
||||||
|
|
||||||
bindings.setApplicationMenu menu
|
bindings.setApplicationMenu menu
|
||||||
else
|
else
|
||||||
windows = BrowserWindow.getAllWindows()
|
windows = BrowserWindow.getAllWindows()
|
||||||
|
|
Loading…
Reference in a new issue