diff --git a/include/wx/webview.h b/include/wx/webview.h index 8b9ac048b3..22bcfd8279 100644 --- a/include/wx/webview.h +++ b/include/wx/webview.h @@ -257,6 +257,7 @@ private: static wxStringWebViewFactoryMap::iterator FindFactory(const wxString &backend); bool m_showMenu; + wxString m_findText; static wxStringWebViewFactoryMap m_factoryMap; wxDECLARE_ABSTRACT_CLASS(wxWebView); diff --git a/interface/wx/webview.h b/interface/wx/webview.h index 4b289e746e..18581d2c9a 100644 --- a/interface/wx/webview.h +++ b/interface/wx/webview.h @@ -317,7 +317,7 @@ public: Edge WebView2. It is available for Windows 7 and newer. The following features are currently unsupported with this backend: - virtual filesystems, custom urls, find. + virtual filesystems, custom urls. This backend is not enabled by default, to build it follow these steps: - Visual Studio 2015, or newer, is required diff --git a/src/common/webview.cpp b/src/common/webview.cpp index 74558b4ee4..8cbcdd1ced 100644 --- a/src/common/webview.cpp +++ b/src/common/webview.cpp @@ -203,10 +203,23 @@ void wxWebView::SelectAll() RunScript("window.getSelection().selectAllChildren(document.body);"); } -long wxWebView::Find(const wxString& WXUNUSED(text), int WXUNUSED(flags)) +long wxWebView::Find(const wxString& text, int flags) { - // TODO: could probably be implemented by script - return -1; + if (text != m_findText) + ClearSelection(); + m_findText = text; + wxString output; + RunScript(wxString::Format("window.find('%s', %s, %s, %s, %s)", + text, + (flags & wxWEBVIEW_FIND_MATCH_CASE) ? "true" : "false", + (flags & wxWEBVIEW_FIND_BACKWARDS) ? "true" : "false", + (flags & wxWEBVIEW_FIND_WRAP) ? "true" : "false", + (flags & wxWEBVIEW_FIND_ENTIRE_WORD) ? "true" : "false" + ), &output); + if (output.IsSameAs("false", false)) + return wxNOT_FOUND; + else + return 1; } // static