Add wxWebViewEvent::IsError()

This commit is contained in:
Tobias Taschner
2021-11-03 13:35:24 +01:00
parent 47833a6d24
commit d31f1dc400
3 changed files with 13 additions and 1 deletions

View File

@@ -300,6 +300,7 @@ public:
m_actionFlags(flags), m_messageHandler(messageHandler)
{}
bool IsError() const { return GetInt() == 0; }
const wxString& GetURL() const { return m_url; }
const wxString& GetTarget() const { return m_target; }

View File

@@ -1345,6 +1345,14 @@ public:
@since 3.1.5
*/
const wxString& GetMessageHandler() const;
/**
Returns true the script execution failed. Only valid for events of type
@c wxEVT_WEBVIEW_SCRIPT_RESULT
@since 3.1.6
*/
bool IsError() const;
};

View File

@@ -932,7 +932,10 @@ void WebFrame::OnScriptMessage(wxWebViewEvent& evt)
void WebFrame::OnScriptResult(wxWebViewEvent& evt)
{
wxLogMessage("Async script result received; value = %s", evt.GetString());
if (evt.IsError())
wxLogError("Async script execution failed: %s", evt.GetString());
else
wxLogMessage("Async script result received; value = %s", evt.GetString());
}
void WebFrame::OnSetPage(wxCommandEvent& WXUNUSED(evt))