]> khamidou — GitHub mirrors - electron.git/commitdiff
Make Menu.popup accept no parameter
authorCheng Zhao <zcbenz@gmail.com>
Wed, 30 Sep 2015 15:41:23 +0000 (23:41 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 30 Sep 2015 15:41:23 +0000 (23:41 +0800)
atom/browser/api/lib/menu.coffee
docs/api/menu.md

index 3595ba1fe7db3384747e8221064ab257fc89b048..f66c1568c003807e12ddbe1812c6e43fbf41300a 100644 (file)
@@ -79,7 +79,11 @@ Menu::_init = ->
         v8Util.setHiddenValue group[0], 'checked', true unless checked
 
 Menu::popup = (window, x, y) ->
-  throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
+  unless window?.constructor is BrowserWindow
+    # Shift.
+    y = x
+    x = window
+    window = BrowserWindow.getFocusedWindow()
   if x? and y?
     @_popupAt(window, x, y)
   else
index f48b07e7e40a95ff77dbff3b836b9ccffdcfff54..cabd04ca855039ef7a681a46c0cc1c52a6c7952c 100644 (file)
@@ -237,9 +237,9 @@ Generally, the `template` is just an array of `options` for constructing a
 You can also attach other fields to the element of the `template` and they
 will become properties of the constructed menu items.
 
-### `Menu.popup(browserWindow[, x, y])`
+### `Menu.popup([browserWindow, x, y])`
 
-* `browserWindow` BrowserWindow
+* `browserWindow` BrowserWindow (optional)
 * `x` Number (optional)
 * `y` Number (**required** if `x` is used)