зеркало из https://github.com/electron/electron.git
views: Show menu on window's content view
This commit is contained in:
Родитель
9c7854aef6
Коммит
413fdc6f0d
|
@ -24,19 +24,16 @@ MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
|||
void MenuViews::PopupAt(BrowserWindow* window,
|
||||
int x, int y, int positioning_item,
|
||||
const base::Closure& callback) {
|
||||
NativeWindow* native_window = static_cast<NativeWindow*>(window->window());
|
||||
auto* native_window = static_cast<NativeWindowViews*>(window->window());
|
||||
if (!native_window)
|
||||
return;
|
||||
auto* web_contents = native_window->inspectable_web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
// (-1, -1) means showing on mouse location.
|
||||
gfx::Point location;
|
||||
if (x == -1 || y == -1) {
|
||||
location = display::Screen::GetScreen()->GetCursorScreenPoint();
|
||||
} else {
|
||||
auto* view = web_contents->GetView()->GetWebView();
|
||||
views::View* view = native_window; // the instance is also its content view
|
||||
gfx::Point origin = view->bounds().origin();
|
||||
location = gfx::Point(origin.x() + x, origin.y() + y);
|
||||
}
|
||||
|
@ -53,7 +50,7 @@ void MenuViews::PopupAt(BrowserWindow* window,
|
|||
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
|
||||
model(), flags, close_callback));
|
||||
menu_runners_[window_id]->RunMenuAt(
|
||||
static_cast<NativeWindowViews*>(window->window())->widget(),
|
||||
native_window->widget(),
|
||||
NULL,
|
||||
gfx::Rect(location, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPLEFT,
|
||||
|
|
Загрузка…
Ссылка в новой задаче