Allow settings modification before WebView Edge init
Setting EnableContextMenu and EnableAccessToDevTools where ignored before the webview loaded content. This would often be set directly after creation and work like this with other backends.
This commit is contained in:
@@ -36,6 +36,8 @@ public:
|
||||
bool m_initialized;
|
||||
bool m_isBusy;
|
||||
wxString m_pendingURL;
|
||||
int m_pendingContextMenuEnabled;
|
||||
int m_pendingAccessToDevToolsEnabled;
|
||||
|
||||
// WebView Events tokens
|
||||
EventRegistrationToken m_navigationStartingToken = { };
|
||||
|
@@ -76,6 +76,8 @@ bool wxWebViewEdgeImpl::Create()
|
||||
{
|
||||
m_initialized = false;
|
||||
m_isBusy = false;
|
||||
m_pendingContextMenuEnabled = -1;
|
||||
m_pendingAccessToDevToolsEnabled = -1;
|
||||
|
||||
m_historyLoadingFromList = false;
|
||||
m_historyEnabled = true;
|
||||
@@ -310,6 +312,18 @@ HRESULT wxWebViewEdgeImpl::OnWebViewCreated(HRESULT result, ICoreWebView2Control
|
||||
this, &wxWebViewEdgeImpl::OnContentLoading).Get(),
|
||||
&m_contentLoadingToken);
|
||||
|
||||
if (m_pendingContextMenuEnabled != -1)
|
||||
{
|
||||
m_ctrl->EnableContextMenu(m_pendingContextMenuEnabled == 1);
|
||||
m_pendingContextMenuEnabled = -1;
|
||||
}
|
||||
|
||||
if (m_pendingAccessToDevToolsEnabled != -1)
|
||||
{
|
||||
m_ctrl->EnableAccessToDevTools(m_pendingAccessToDevToolsEnabled == 1);
|
||||
m_pendingContextMenuEnabled = -1;
|
||||
}
|
||||
|
||||
if (!m_pendingURL.empty())
|
||||
{
|
||||
m_ctrl->LoadURL(m_pendingURL);
|
||||
@@ -706,6 +720,8 @@ void wxWebViewEdge::EnableContextMenu(bool enable)
|
||||
wxCOMPtr<ICoreWebView2Settings> settings(m_impl->GetSettings());
|
||||
if (settings)
|
||||
settings->put_AreDefaultContextMenusEnabled(enable);
|
||||
else
|
||||
m_impl->m_pendingContextMenuEnabled = enable ? 1 : 0;
|
||||
}
|
||||
|
||||
bool wxWebViewEdge::IsContextMenuEnabled() const
|
||||
@@ -727,6 +743,8 @@ void wxWebViewEdge::EnableAccessToDevTools(bool enable)
|
||||
wxCOMPtr<ICoreWebView2Settings> settings(m_impl->GetSettings());
|
||||
if (settings)
|
||||
settings->put_AreDevToolsEnabled(enable);
|
||||
else
|
||||
m_impl->m_pendingAccessToDevToolsEnabled = enable ? 1 : 0;
|
||||
}
|
||||
|
||||
bool wxWebViewEdge::IsAccessToDevToolsEnabled() const
|
||||
|
Reference in New Issue
Block a user