Implement GetSelectedSource for the OSX WebKit backend.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -108,7 +108,7 @@ public:
|
|||||||
virtual bool HasSelection();
|
virtual bool HasSelection();
|
||||||
virtual void SelectAll();
|
virtual void SelectAll();
|
||||||
virtual wxString GetSelectedText();
|
virtual wxString GetSelectedText();
|
||||||
virtual wxString GetSelectedSource() { return ""; }
|
virtual wxString GetSelectedSource();
|
||||||
virtual void ClearSelection();
|
virtual void ClearSelection();
|
||||||
|
|
||||||
void RunScript(const wxString& javascript);
|
void RunScript(const wxString& javascript);
|
||||||
|
@@ -925,6 +925,17 @@ void wxWebViewWebKit::SelectAll()
|
|||||||
RunScript("window.getSelection().selectAllChildren(document.body);");
|
RunScript("window.getSelection().selectAllChildren(document.body);");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString wxWebViewWebKit::GetSelectedSource()
|
||||||
|
{
|
||||||
|
wxString script = ("var range = window.getSelection().getRangeAt(0);"
|
||||||
|
"var element = document.createElement('div');"
|
||||||
|
"element.appendChild(range.cloneContents());"
|
||||||
|
"return element.innerHTML;");
|
||||||
|
id result = [[m_webView windowScriptObject]
|
||||||
|
evaluateWebScript:wxNSStringWithWxString(script)];
|
||||||
|
return wxStringWithNSString([result stringValue]);
|
||||||
|
}
|
||||||
|
|
||||||
wxString wxWebViewWebKit::GetPageText()
|
wxString wxWebViewWebKit::GetPageText()
|
||||||
{
|
{
|
||||||
id result = [[m_webView windowScriptObject]
|
id result = [[m_webView windowScriptObject]
|
||||||
|
Reference in New Issue
Block a user