Merge pull request #6280 from electron/pop-up-context-menu-windows

Use previously set context menu when popup menu is null
This commit is contained in:
Kevin Sawicki 2016-06-29 13:00:10 -07:00 committed by GitHub
commit 7279fc46bc
2 changed files with 4 additions and 3 deletions

View file

@ -263,7 +263,7 @@ const CGFloat kVerticalTitleMargin = 2;
} }
if (menuController_ && ![menuController_ isMenuOpen]) { if (menuController_ && ![menuController_ isMenuOpen]) {
// Redraw the dray icon to show highlight if it is enabled. // Redraw the tray icon to show highlight if it is enabled.
[self setNeedsDisplay:YES]; [self setNeedsDisplay:YES];
[statusItem_ popUpStatusItemMenu:[menuController_ menu]]; [statusItem_ popUpStatusItemMenu:[menuController_ menu]];
// The popUpStatusItemMenu returns only after the showing menu is closed. // The popUpStatusItemMenu returns only after the showing menu is closed.

View file

@ -134,8 +134,9 @@ void NotifyIcon::DisplayBalloon(HICON icon,
void NotifyIcon::PopUpContextMenu(const gfx::Point& pos, void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
ui::SimpleMenuModel* menu_model) { ui::SimpleMenuModel* menu_model) {
// Returns if context menu isn't set. // Returns if context menu isn't set.
if (!menu_model) if (menu_model == nullptr && menu_model_ == nullptr)
return; return;
// Set our window as the foreground window, so the context menu closes when // Set our window as the foreground window, so the context menu closes when
// we click away from it. // we click away from it.
if (!SetForegroundWindow(window_)) if (!SetForegroundWindow(window_))
@ -147,7 +148,7 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
rect.set_origin(gfx::Screen::GetScreen()->GetCursorScreenPoint()); rect.set_origin(gfx::Screen::GetScreen()->GetCursorScreenPoint());
views::MenuRunner menu_runner( views::MenuRunner menu_runner(
menu_model, menu_model != nullptr ? menu_model : menu_model_,
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS); views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
ignore_result(menu_runner.RunMenuAt( ignore_result(menu_runner.RunMenuAt(
NULL, NULL, rect, views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE)); NULL, NULL, rect, views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE));