From c6ea1fdaf924be4ee49a19d12f76e4fcd257bb0a Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Sat, 6 Aug 2011 12:48:22 +0000 Subject: [PATCH 1/1] Implement GetPageText for the OSX WebKit implementation. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68570 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/webview_webkit.h | 2 +- src/osx/webview_webkit.mm | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/wx/osx/webview_webkit.h b/include/wx/osx/webview_webkit.h index 5310a3ed19..b15c2511cd 100644 --- a/include/wx/osx/webview_webkit.h +++ b/include/wx/osx/webview_webkit.h @@ -58,7 +58,7 @@ public: virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT); virtual void Stop(); virtual wxString GetPageSource(); - virtual wxString GetPageText() { return ""; } + virtual wxString GetPageText(); //We do not want to hide the other overloads using wxWebView::SetPage; diff --git a/src/osx/webview_webkit.mm b/src/osx/webview_webkit.mm index 838db3dec3..9b4955a17f 100644 --- a/src/osx/webview_webkit.mm +++ b/src/osx/webview_webkit.mm @@ -920,6 +920,13 @@ void wxWebViewWebKit::ClearSelection() RunScript("window.getSelection().removeAllRanges();"); } +wxString wxWebViewWebKit::GetPageText() +{ + id result = [[m_webView windowScriptObject] + evaluateWebScript:@"document.body.textContent"]; + return wxStringWithNSString([result stringValue]); +} + void wxWebViewWebKit::EnableHistory(bool enable) { if ( !m_webView ) -- 2.45.2