Add 'tray.popContextMenu()' Windows implementation.
This commit is contained in:
parent
4421fbf9f3
commit
ed4c69343f
6 changed files with 26 additions and 23 deletions
|
@ -62,24 +62,7 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
|
|||
}
|
||||
|
||||
NotifyRightClicked(gfx::Rect(rect));
|
||||
|
||||
if (!menu_model_)
|
||||
return;
|
||||
|
||||
// Set our window as the foreground window, so the context menu closes when
|
||||
// we click away from it.
|
||||
if (!SetForegroundWindow(window_))
|
||||
return;
|
||||
|
||||
views::MenuRunner menu_runner(
|
||||
menu_model_,
|
||||
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
|
||||
ignore_result(menu_runner.RunMenuAt(
|
||||
NULL,
|
||||
NULL,
|
||||
gfx::Rect(cursor_pos, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPLEFT,
|
||||
ui::MENU_SOURCE_MOUSE));
|
||||
PopContextMenu(cursor_pos);
|
||||
}
|
||||
|
||||
void NotifyIcon::ResetIcon() {
|
||||
|
@ -152,6 +135,23 @@ void NotifyIcon::DisplayBalloon(const gfx::Image& icon,
|
|||
LOG(WARNING) << "Unable to create status tray balloon.";
|
||||
}
|
||||
|
||||
void NotifyIcon::PopContextMenu(const gfx::Point& pos) {
|
||||
// Set our window as the foreground window, so the context menu closes when
|
||||
// we click away from it.
|
||||
if (!SetForegroundWindow(window_))
|
||||
return;
|
||||
|
||||
views::MenuRunner menu_runner(
|
||||
menu_model_,
|
||||
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
|
||||
ignore_result(menu_runner.RunMenuAt(
|
||||
NULL,
|
||||
NULL,
|
||||
gfx::Rect(pos, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPLEFT,
|
||||
ui::MENU_SOURCE_MOUSE));
|
||||
}
|
||||
|
||||
void NotifyIcon::SetContextMenu(ui::SimpleMenuModel* menu_model) {
|
||||
menu_model_ = menu_model;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue