diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index 202947092a8b..da208b365911 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -40,7 +40,6 @@ void Menu::AfterInit(v8::Isolate* isolate) { delegate.Get("getAcceleratorForCommandId", &get_accelerator_); delegate.Get("executeCommand", &execute_command_); delegate.Get("menuWillShow", &menu_will_show_); - delegate.Get("menuClosed", &menu_closed_); } bool Menu::IsCommandIdChecked(int command_id) const { @@ -76,10 +75,6 @@ void Menu::MenuWillShow(ui::SimpleMenuModel* source) { menu_will_show_.Run(); } -void Menu::MenuClosed(ui::SimpleMenuModel* source) { - menu_closed_.Run(); -} - void Menu::InsertItemAt( int index, int command_id, const base::string16& label) { model_->InsertItemAt(index, command_id, label); diff --git a/atom/browser/api/atom_api_menu.h b/atom/browser/api/atom_api_menu.h index 8d07c8bbd7f8..574d218024a7 100644 --- a/atom/browser/api/atom_api_menu.h +++ b/atom/browser/api/atom_api_menu.h @@ -52,7 +52,6 @@ class Menu : public mate::TrackableObject, ui::Accelerator* accelerator) const override; void ExecuteCommand(int command_id, int event_flags) override; void MenuWillShow(ui::SimpleMenuModel* source) override; - void MenuClosed(ui::SimpleMenuModel* source) override; virtual void PopupAt(Window* window, int x, int y, int positioning_item, const base::Closure& callback) = 0; @@ -95,7 +94,6 @@ class Menu : public mate::TrackableObject, base::Callback(int, bool)> get_accelerator_; base::Callback, int)> execute_command_; base::Callback menu_will_show_; - base::Callback menu_closed_; DISALLOW_COPY_AND_ASSIGN(Menu); }; diff --git a/docs/api/menu.md b/docs/api/menu.md index 2dea1c8eb9f8..d6323ac17853 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -115,13 +115,6 @@ can have a submenu. Objects created with `new Menu` or returned by `Menu.buildFromTemplate` emit the following events: -#### Event: 'closed' - -Emitted when the menu is closed. - -Note that one menu can be shown for multiple windows, and in this case the -`closed` event would be emitted for multiple times. - ## Examples The `Menu` class is only available in the main process, but you can also use it diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index c0e9c202ef54..b8b4a60e4196 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -39,9 +39,6 @@ Menu.prototype._init = function () { const found = this.groupsMap[id].find(item => item.checked) || null if (!found) v8Util.setHiddenValue(this.groupsMap[id][0], 'checked', true) } - }, - menuClosed: () => { - this.emit('closed') } } } diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 2d84e9f564af..71e57ebee908 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -280,8 +280,7 @@ WebContents.prototype._init = function () { this.on('pepper-context-menu', function (event, params, callback) { // Access Menu via electron.Menu to prevent circular require. const menu = electron.Menu.buildFromTemplate(params.menu) - menu.once('closed', callback) - menu.popup(event.sender.getOwnerBrowserWindow(), params.x, params.y) + menu.popup(event.sender.getOwnerBrowserWindow(), params.x, params.y, callback) }) // The devtools requests the webContents to reload. diff --git a/spec/api-menu-spec.js b/spec/api-menu-spec.js index a15fd5f83cda..08835f3ad8f0 100644 --- a/spec/api-menu-spec.js +++ b/spec/api-menu-spec.js @@ -335,37 +335,6 @@ describe('Menu module', () => { }) }) - describe('Menu.closePopup()', () => { - let w = null - let menu - - beforeEach((done) => { - w = new BrowserWindow({show: false, width: 200, height: 200}) - menu = Menu.buildFromTemplate([ - { - label: '1' - } - ]) - - w.loadURL('data:text/html,teszt') - w.webContents.on('dom-ready', () => { - done() - }) - }) - - afterEach(() => { - return closeWindow(w).then(() => { w = null }) - }) - - it('emits closed event', (done) => { - menu.popup(w, {x: 100, y: 100}) - menu.on('closed', () => { - done() - }) - menu.closePopup(w) - }) - }) - describe('Menu.setApplicationMenu', () => { it('sets a menu', () => { const menu = Menu.buildFromTemplate([