From 0fb68e8130841282d7e605d165c9d1ced84ff103 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 30 Sep 2015 23:41:23 +0800 Subject: [PATCH] Make Menu.popup accept no parameter --- atom/browser/api/lib/menu.coffee | 6 +++++- docs/api/menu.md | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/lib/menu.coffee b/atom/browser/api/lib/menu.coffee index 3595ba1fe7..f66c1568c0 100644 --- a/atom/browser/api/lib/menu.coffee +++ b/atom/browser/api/lib/menu.coffee @@ -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 diff --git a/docs/api/menu.md b/docs/api/menu.md index f48b07e7e4..cabd04ca85 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -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)