WebViewEdge: Forward window visibility to SDK

Tell the SDK controller if the control is shown or hidden.
This allows creating a hidden webview which will be shown later
and might fix other potential issues.
This commit is contained in:
Tobias Taschner
2020-11-05 09:27:20 +01:00
parent 412de05407
commit 2d9c08e0cc
2 changed files with 11 additions and 0 deletions

View File

@@ -134,6 +134,8 @@ private:
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
void OnShow(wxShowEvent& event);
bool RunScriptSync(const wxString& javascript, wxString* output = NULL); bool RunScriptSync(const wxString& javascript, wxString* output = NULL);
wxDECLARE_DYNAMIC_CLASS(wxWebViewEdge); wxDECLARE_DYNAMIC_CLASS(wxWebViewEdge);

View File

@@ -364,6 +364,7 @@ bool wxWebViewEdge::IsAvailable()
wxWebViewEdge::~wxWebViewEdge() wxWebViewEdge::~wxWebViewEdge()
{ {
Unbind(wxEVT_SHOW, &wxWebViewEdge::OnShow, this);
delete m_impl; delete m_impl;
} }
@@ -388,6 +389,7 @@ bool wxWebViewEdge::Create(wxWindow* parent,
if (!m_impl->Create()) if (!m_impl->Create())
return false; return false;
Bind(wxEVT_SIZE, &wxWebViewEdge::OnSize, this); Bind(wxEVT_SIZE, &wxWebViewEdge::OnSize, this);
Bind(wxEVT_SHOW, &wxWebViewEdge::OnShow, this);
LoadURL(url); LoadURL(url);
return true; return true;
@@ -399,6 +401,13 @@ void wxWebViewEdge::OnSize(wxSizeEvent& event)
event.Skip(); event.Skip();
} }
void wxWebViewEdge::OnShow(wxShowEvent& event)
{
if (m_impl->m_webView)
m_impl->m_webViewController->put_IsVisible(event.IsShown());
event.Skip();
}
void wxWebViewEdge::LoadURL(const wxString& url) void wxWebViewEdge::LoadURL(const wxString& url)
{ {
if (!m_impl->m_webView) if (!m_impl->m_webView)