minimize: 'minimize'
close: 'close'
+# Maps methods that should be called directly on the BrowserWindow instance
+methodInBrowserWindow =
+ minimize: true
+ close: true
+
class MenuItem
@types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
# Manually flip the checked flags when clicked.
@checked = !@checked if @type in ['checkbox', 'radio']
- if @role and rolesMap[@role] and process.platform isnt 'darwin'
- focusedWindow?[rolesMap[@role]]()
+ if @role and rolesMap[@role] and process.platform isnt 'darwin' and focusedWindow?
+ methodName = rolesMap[@role]
+ if methodInBrowserWindow[methodName]
+ focusedWindow[methodName]()
+ else
+ focusedWindow.webContents?[methodName]()
else if typeof click is 'function'
click this, focusedWindow
else if typeof @selector is 'string'