Identify script handler in message event
This commit is contained in:
@@ -270,9 +270,10 @@ public:
|
||||
wxWebViewEvent() {}
|
||||
wxWebViewEvent(wxEventType type, int id, const wxString& url,
|
||||
const wxString target,
|
||||
wxWebViewNavigationActionFlags flags = wxWEBVIEW_NAV_ACTION_NONE)
|
||||
wxWebViewNavigationActionFlags flags = wxWEBVIEW_NAV_ACTION_NONE,
|
||||
const wxString& messageHandler = wxString())
|
||||
: wxNotifyEvent(type, id), m_url(url), m_target(target),
|
||||
m_actionFlags(flags)
|
||||
m_actionFlags(flags), m_messageHandler(messageHandler)
|
||||
{}
|
||||
|
||||
|
||||
@@ -280,12 +281,14 @@ public:
|
||||
const wxString& GetTarget() const { return m_target; }
|
||||
|
||||
wxWebViewNavigationActionFlags GetNavigationAction() const { return m_actionFlags; }
|
||||
const wxString& GetMessageHandler() const { return m_messageHandler; }
|
||||
|
||||
virtual wxEvent* Clone() const wxOVERRIDE { return new wxWebViewEvent(*this); }
|
||||
private:
|
||||
wxString m_url;
|
||||
wxString m_target;
|
||||
wxWebViewNavigationActionFlags m_actionFlags;
|
||||
wxString m_messageHandler;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWebViewEvent);
|
||||
};
|
||||
|
@@ -1111,7 +1111,8 @@ public:
|
||||
wxWebViewEvent();
|
||||
wxWebViewEvent(wxEventType type, int id, const wxString href,
|
||||
const wxString target,
|
||||
wxWebViewNavigationActionFlags flags = wxWEBVIEW_NAV_ACTION_NONE);
|
||||
wxWebViewNavigationActionFlags flags = wxWEBVIEW_NAV_ACTION_NONE,
|
||||
const wxString& messageHandler = wxString());
|
||||
|
||||
/**
|
||||
Get the name of the target frame which the url of this event
|
||||
@@ -1132,6 +1133,14 @@ public:
|
||||
@since 3.1.2
|
||||
*/
|
||||
wxWebViewNavigationActionFlags GetNavigationAction() const;
|
||||
|
||||
/**
|
||||
Get the name of the script handler. Only valid for events of type
|
||||
@c wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED
|
||||
|
||||
@since 3.1.5
|
||||
*/
|
||||
const wxString& GetMessageHandler() const;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -910,7 +910,7 @@ void WebFrame::OnFullScreenChanged(wxWebViewEvent & evt)
|
||||
|
||||
void WebFrame::OnScriptMessage(wxWebViewEvent& evt)
|
||||
{
|
||||
wxLogMessage("Script message recieved; value = %s", evt.GetString());
|
||||
wxLogMessage("Script message recieved; value = %s, handler = %s", evt.GetString(), evt.GetMessageHandler());
|
||||
}
|
||||
|
||||
void WebFrame::OnSetPage(wxCommandEvent& WXUNUSED(evt))
|
||||
|
@@ -923,7 +923,9 @@ WX_API_AVAILABLE_MACOS(10, 12)
|
||||
wxWebViewEvent event(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED,
|
||||
webKitWindow->GetId(),
|
||||
webKitWindow->GetCurrentURL(),
|
||||
"");
|
||||
"",
|
||||
wxWEBVIEW_NAV_ACTION_NONE,
|
||||
wxCFStringRef::AsString(message.name));
|
||||
if ([message.body isKindOfClass:NSString.class])
|
||||
event.SetString(wxCFStringRef::AsString(message.body));
|
||||
else if ([message.body isKindOfClass:NSNumber.class])
|
||||
|
Reference in New Issue
Block a user