Version: 3.3.0
wxWebViewWindowFeatures Class Referenceabstract

#include <wx/webview.h>

Detailed Description

A class describing the window information for a new child window.

An object of this class can be obtained using wxWebViewEvent::GetTargetWindowFeatures() while handling wxEVT_WEBVIEW_NEWWINDOW_FEATURES.

If a wxEVT_WEBVIEW_NEWWINDOW is not vetoed, a wxEVT_WEBVIEW_NEWWINDOW_FEATURES event will be sent to the application. The application can then create a new window and call wxWebViewEvent::GetTargetWindowInfo() to get this class providing information about the new window. A new child web view will be available via GetChildWebView(). The application can then place the child web view into the new window by calling wxWebView::Create() on the child web view.

Sample JavaScript opening a new window:

window.open("https://www.wxwidgets.org", "newWindow", "width=400,height=400");

Sample C++ code handling a new window request:

// Bind new window handler
m_webView->Bind(wxEVT_WEBVIEW_NEWWINDOW, [](wxWebViewEvent& evt) {
if (evt.GetURL() == "http://badwebsite.com")
evt.Veto(); // Disallow new window for badwebsite.com
else
evt.Skip(); // Allow new window for all other websites
});
// Bind new window features handler
// Get target window features
// Create a top level window for the child web view
wxWindow* win = new wxWindow(this, wxID_ANY, features->GetPosition(), features->GetSize());
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
win->SetSizer(sizer);
// Get the child web view
wxWebView* childWebView = features->GetChildWebView();
// Place the child web view into the window
childWebView->Create(win, wxID_ANY);
sizer->Add(childWebView, wxSizerFlags().Proportion(1).Expand());
}
The basic idea behind a box sizer is that windows will most often be laid out in rather simple basic ...
Definition: sizer.h:2064
void Skip(bool skip=true)
This method can be used inside an event handler to control whether further event handlers bound to th...
void Veto()
Prevents the change announced by this event from happening.
Container for sizer items flags providing readable names for them.
Definition: sizer.h:1442
wxSizer is the abstract base class used for laying out subwindows in a window.
Definition: sizer.h:121
wxSizerItem * Add(wxWindow *window, const wxSizerFlags &flags)
Appends a child to the sizer.
A navigation event holds information about events associated with wxWebView objects.
Definition: webview.h:2053
const wxString & GetURL() const
Get the URL being visited.
wxWebViewWindowFeatures * GetTargetWindowFeatures() const
Get information about the target window.
This control may be used to render web (HTML / CSS / JavaScript) documents.
Definition: webview.h:1027
virtual bool Create(wxWindow *parent, wxWindowID id, const wxString &url=wxWebViewDefaultURLStr, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxWebViewNameStr)=0
Creation function for two-step creation.
A class describing the window information for a new child window.
Definition: webview.h:234
wxWebView * GetChildWebView()
Get the child web view for the target window.
virtual wxSize GetSize() const =0
Returns the size of the new window if specified by a window.open() call.
virtual wxPoint GetPosition() const =0
Returns the position of the new window if specified by a window.open() call.
wxWindow is the base class for all windows and represents any visible object on screen.
Definition: window.h:353
void SetSizer(wxSizer *sizer, bool deleteOld=true)
Sets the window to have the given layout sizer.
@ wxVERTICAL
Definition: defs.h:28
@ wxID_ANY
Any id: means that we don't care about the id, whether when installing an event handler or when creat...
Definition: defs.h:590
wxEventType wxEVT_WEBVIEW_NEWWINDOW_FEATURES
Definition: webview.h:2127
wxEventType wxEVT_WEBVIEW_NEWWINDOW
Definition: webview.h:2126
Since
3.3.0

Public Member Functions

wxWebViewGetChildWebView ()
 Get the child web view for the target window. More...
 
virtual wxPoint GetPosition () const =0
 Returns the position of the new window if specified by a window.open() call. More...
 
virtual wxSize GetSize () const =0
 Returns the size of the new window if specified by a window.open() call. More...
 
virtual bool ShouldDisplayMenuBar () const =0
 Returns true if the target window is expected to display a menu bar as specified by a window.open() call. More...
 
virtual bool ShouldDisplayStatusBar () const =0
 Returns true if the target window is expected to display a status bar as specified by a window.open() call. More...
 
virtual bool ShouldDisplayToolBar () const =0
 Returns true if the target window is expected to display a tool bar as specified by a window.open() call. More...
 
virtual bool ShouldDisplayScrollBars () const =0
 Returns true if the target window is expected to display scroll bars as specified by a window.open() call. More...
 

Member Function Documentation

◆ GetChildWebView()

wxWebView* wxWebViewWindowFeatures::GetChildWebView ( )

Get the child web view for the target window.

This is available in the event handler for wxEVT_WEBVIEW_NEWWINDOW_FEATURES and wxWebView::Create() must be called on the child web view directly.

The requested URL will be loaded automatically in the child web view.

◆ GetPosition()

virtual wxPoint wxWebViewWindowFeatures::GetPosition ( ) const
pure virtual

Returns the position of the new window if specified by a window.open() call.

◆ GetSize()

virtual wxSize wxWebViewWindowFeatures::GetSize ( ) const
pure virtual

Returns the size of the new window if specified by a window.open() call.

◆ ShouldDisplayMenuBar()

virtual bool wxWebViewWindowFeatures::ShouldDisplayMenuBar ( ) const
pure virtual

Returns true if the target window is expected to display a menu bar as specified by a window.open() call.

◆ ShouldDisplayScrollBars()

virtual bool wxWebViewWindowFeatures::ShouldDisplayScrollBars ( ) const
pure virtual

Returns true if the target window is expected to display scroll bars as specified by a window.open() call.

◆ ShouldDisplayStatusBar()

virtual bool wxWebViewWindowFeatures::ShouldDisplayStatusBar ( ) const
pure virtual

Returns true if the target window is expected to display a status bar as specified by a window.open() call.

◆ ShouldDisplayToolBar()

virtual bool wxWebViewWindowFeatures::ShouldDisplayToolBar ( ) const
pure virtual

Returns true if the target window is expected to display a tool bar as specified by a window.open() call.