Add wxWebView::RunScriptAsync()

This commit is contained in:
Tobias Taschner
2021-04-07 22:21:04 +02:00
committed by Tobias Taschner
parent cf6a947dab
commit e9dc74cb6d
4 changed files with 74 additions and 36 deletions

View File

@@ -88,7 +88,7 @@ public:
virtual bool SetUserAgent(const wxString& userAgent) wxOVERRIDE;
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) const wxOVERRIDE;
virtual void RunScriptAsync(const wxString& javascript, void* clientData = NULL) const wxOVERRIDE;
virtual bool AddScriptMessageHandler(const wxString& name) wxOVERRIDE;
virtual bool RemoveScriptMessageHandler(const wxString& name) wxOVERRIDE;
virtual bool AddUserScript(const wxString& javascript,

View File

@@ -191,7 +191,8 @@ public:
virtual wxString GetUserAgent() const;
// Script
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) const = 0;
virtual bool RunScript(const wxString& javascript, wxString* output = NULL) const;
virtual void RunScriptAsync(const wxString& javascript, void* clientData = NULL) const;
virtual bool AddScriptMessageHandler(const wxString& name)
{ wxUnusedVar(name); return false; }
virtual bool RemoveScriptMessageHandler(const wxString& name)
@@ -267,6 +268,9 @@ protected:
bool QueryCommandEnabled(const wxString& command) const;
void ExecCommand(const wxString& command);
void SendScriptResult(void* clientData, bool success,
const wxString& output) const;
// Count the number of calls to RunScript() in order to prevent
// the_same variable from being used twice in more than one call.
mutable int m_runScriptCount;
@@ -276,6 +280,8 @@ private:
static wxStringWebViewFactoryMap::iterator FindFactory(const wxString &backend);
bool m_showMenu;
mutable int m_syncScriptResult;
mutable wxString m_syncScriptOutput;
wxString m_findText;
static wxStringWebViewFactoryMap m_factoryMap;
@@ -319,6 +325,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_NEWWINDOW, wxWebVie
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_TITLE_CHANGED, wxWebViewEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_FULLSCREEN_CHANGED, wxWebViewEvent);
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, wxWebViewEvent);
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_WEBVIEW, wxEVT_WEBVIEW_SCRIPT_RESULT, wxWebViewEvent);
typedef void (wxEvtHandler::*wxWebViewEventFunction)
(wxWebViewEvent&);