}
void MenuViews::Popup(Window* window) {
- PopupAtPoint(window, gfx::Screen::GetNativeScreen()->GetCursorScreenPoint());
+ PopupAt(window, -1, -1, 0);
}
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
if (!view)
return;
- gfx::Point origin = view->GetViewBounds().origin();
- PopupAtPoint(window, gfx::Point(origin.x() + x, origin.y() + y));
-}
+ // (-1, -1) means showing on mouse location.
+ gfx::Point location;
+ if (x == -1 || y == -1) {
+ location = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
+ } else {
+ gfx::Point origin = view->GetViewBounds().origin();
+ location = gfx::Point(origin.x() + x, origin.y() + y);
+ }
-void MenuViews::PopupAtPoint(Window* window, const gfx::Point& point) {
+ // Show the menu.
views::MenuRunner menu_runner(
model(),
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS);
ignore_result(menu_runner.RunMenuAt(
static_cast<NativeWindowViews*>(window->window())->widget(),
NULL,
- gfx::Rect(point, gfx::Size()),
+ gfx::Rect(location, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT,
ui::MENU_SOURCE_MOUSE));
}