Allow distinguishing user- from script-opened wxWebView windows

Add wxWebViewEvent::GetNavigationAction() returning a value that can be
either wxWEBVIEW_NAV_ACTION_USER for the links opened by the user, or
wxWEBVIEW_NAV_ACTION_OTHER for the other ones (e.g. opened from
JavaScript code on the page).

Closes #15402.
This commit is contained in:
Steven Lamerton
2018-08-19 22:27:34 +02:00
committed by Vadim Zeitlin
parent 91aa6ba36e
commit b61123cd7d
7 changed files with 84 additions and 13 deletions

View File

@@ -92,6 +92,21 @@ enum wxWebViewFindFlags
wxWEBVIEW_FIND_DEFAULT = 0
};
/**
Navigation action types.
@since 3.1.2
*/
enum wxWebViewNavigationActionFlags
{
/** No navigation action */
wxWEBVIEW_NAV_ACTION_NONE,
/** The navigation was started by the user */
wxWEBVIEW_NAV_ACTION_USER,
/**The navigation was started but not by the user*/
wxWEBVIEW_NAV_ACTION_OTHER
};
/**
@class wxWebViewHistoryItem
@@ -881,7 +896,8 @@ class wxWebViewEvent : public wxNotifyEvent
public:
wxWebViewEvent();
wxWebViewEvent(wxEventType type, int id, const wxString href,
const wxString target);
const wxString target,
wxWebViewNavigationActionFlags flags = wxWEBVIEW_NAV_ACTION_NONE);
/**
Get the name of the target frame which the url of this event
@@ -894,6 +910,14 @@ public:
Get the URL being visited
*/
const wxString& GetURL() const;
/**
Get the type of navigation action. Only valid for events of type
@c wxEVT_WEBVIEW_NEWWINDOW
@since 3.1.2
*/
wxWebViewNavigationActionFlags GetNavigationAction() const;
};