Merge pull request #3542 from etiktin/fix_menu_item_using_deprcated_api
Fix menu-item using deprecated API
This commit is contained in:
commit
360a747acf
1 changed files with 11 additions and 2 deletions
|
@ -13,6 +13,11 @@ rolesMap =
|
||||||
minimize: 'minimize'
|
minimize: 'minimize'
|
||||||
close: 'close'
|
close: 'close'
|
||||||
|
|
||||||
|
# Maps methods that should be called directly on the BrowserWindow instance
|
||||||
|
methodInBrowserWindow =
|
||||||
|
minimize: true
|
||||||
|
close: true
|
||||||
|
|
||||||
class MenuItem
|
class MenuItem
|
||||||
@types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
|
@types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
|
||||||
|
|
||||||
|
@ -42,8 +47,12 @@ class MenuItem
|
||||||
# Manually flip the checked flags when clicked.
|
# Manually flip the checked flags when clicked.
|
||||||
@checked = !@checked if @type in ['checkbox', 'radio']
|
@checked = !@checked if @type in ['checkbox', 'radio']
|
||||||
|
|
||||||
if @role and rolesMap[@role] and process.platform isnt 'darwin'
|
if @role and rolesMap[@role] and process.platform isnt 'darwin' and focusedWindow?
|
||||||
focusedWindow?[rolesMap[@role]]()
|
methodName = rolesMap[@role]
|
||||||
|
if methodInBrowserWindow[methodName]
|
||||||
|
focusedWindow[methodName]()
|
||||||
|
else
|
||||||
|
focusedWindow.webContents?[methodName]()
|
||||||
else if typeof click is 'function'
|
else if typeof click is 'function'
|
||||||
click this, focusedWindow
|
click this, focusedWindow
|
||||||
else if typeof @selector is 'string'
|
else if typeof @selector is 'string'
|
||||||
|
|
Loading…
Reference in a new issue