This API shows the system-provided pop-up dictionary.
Some Mac apps including Chrome have "Look Up in in Dictionary" context
menu item. This API can be used to implement it.
return window_->IsMenuBarVisible();
}
+#if defined(OS_MACOSX)
+void Window::ShowDefinitionForSelection() {
+ window_->ShowDefinitionForSelection();
+}
+#endif
+
mate::Handle<WebContents> Window::GetWebContents(v8::Isolate* isolate) const {
return WebContents::CreateFrom(isolate, window_->GetWebContents());
}
.SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide)
.SetMethod("setMenuBarVisibility", &Window::SetMenuBarVisibility)
.SetMethod("isMenuBarVisible", &Window::IsMenuBarVisible)
+#if defined(OS_MACOSX)
+ .SetMethod(
+ "showDefinitionForSelection", &Window::ShowDefinitionForSelection)
+#endif
.SetMethod("_getWebContents", &Window::GetWebContents)
.SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents);
}
void SetMenuBarVisibility(bool visible);
bool IsMenuBarVisible();
+#if defined(OS_MACOSX)
+ void ShowDefinitionForSelection();
+#endif
+
// APIs for WebContents.
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
mate::Handle<WebContents> GetDevToolsWebContents(v8::Isolate* isolate) const;
PrintNow(silent, print_background);
}
+void NativeWindow::ShowDefinitionForSelection() {
+ NOTIMPLEMENTED();
+}
+
void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {
}
// Print current page.
virtual void Print(bool silent, bool print_background);
+ // Show popup dictionary.
+ virtual void ShowDefinitionForSelection();
+
// Toggle the menu bar.
virtual void SetAutoHideMenuBar(bool auto_hide);
virtual bool IsMenuBarAutoHide();
#import <Cocoa/Cocoa.h>
+#include <string>
+#include <vector>
+
#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "atom/browser/native_window.h"
virtual bool HasModalDialog() OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
virtual void SetProgressBar(double progress) OVERRIDE;
+ virtual void ShowDefinitionForSelection() OVERRIDE;
// Returns true if |point| in local Cocoa coordinate system falls within
// the draggable region.
[dock_tile display];
}
+void NativeWindowMac::ShowDefinitionForSelection() {
+ content::WebContents* web_contents = GetWebContents();
+ content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
+ if (!rwhv)
+ return;
+ rwhv->ShowDefinitionForSelection();
+}
+
bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const {
if (!draggable_region_)
return false;
the `*.desktop` file name to `desktopName` field in `package.json`. By default,
it will assume `app.getName().desktop`.
+### BrowserWindow.showDefinitionForSelection()
+
+Show pop-up dictionary that searches the selected word on the page.
+This API is available only on Mac OS.
+
### BrowserWindow.setAutoHideMenuBar(hide)
* `hide` Boolean