| Version: 3.3.1

Public Member Functions | List of all members
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
m_webView->Bind(wxEVT_WEBVIEW_NEWWINDOW_FEATURES, [](wxWebViewEvent& evt) {
// Get target window features
wxWebViewWindowFeatures* features = evt.GetTargetWindowFeatures();
// 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());
}
wxBoxSizer
The basic idea behind a box sizer is that windows will most often be laid out in rather simple basic ...
Definition: sizer.h:2070
wxEvent::Skip
void Skip(bool skip=true)
This method can be used inside an event handler to control whether further event handlers bound to th...
wxNotifyEvent::Veto
void Veto()
Prevents the change announced by this event from happening.
wxSizerFlags
Container for sizer items flags providing readable names for them.
Definition: sizer.h:1442
wxSizer
wxSizer is the abstract base class used for laying out subwindows in a window.
Definition: sizer.h:121
wxSizer::Add
wxSizerItem * Add(wxWindow *window, const wxSizerFlags &flags)
Appends a child to the sizer.
wxWebViewEvent
A navigation event holds information about events associated with wxWebView objects.
Definition: webview.h:2055
wxWebViewEvent::GetURL
const wxString & GetURL() const
Get the URL being visited.
wxWebViewEvent::GetTargetWindowFeatures
wxWebViewWindowFeatures * GetTargetWindowFeatures() const
Get information about the target window.
wxWebView
This control may be used to render web (HTML / CSS / JavaScript) documents.
Definition: webview.h:1029
wxWebView::Create
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.
wxWebViewWindowFeatures
A class describing the window information for a new child window.
Definition: webview.h:234
wxWebViewWindowFeatures::GetChildWebView
wxWebView * GetChildWebView()
Get the child web view for the target window.
wxWebViewWindowFeatures::GetSize
virtual wxSize GetSize() const =0
Returns the size of the new window if specified by a window.open() call.
wxWebViewWindowFeatures::GetPosition
virtual wxPoint GetPosition() const =0
Returns the position of the new window if specified by a window.open() call.
wxWindow
wxWindow is the base class for all windows and represents any visible object on screen.
Definition: window.h:353
wxWindow::SetSizer
void SetSizer(wxSizer *sizer, bool deleteOld=true)
Sets the window to have the given layout sizer.
wxVERTICAL
@ wxVERTICAL
Definition: defs.h:28
wxID_ANY
@ 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:591
wxEVT_WEBVIEW_NEWWINDOW_FEATURES
wxEventType wxEVT_WEBVIEW_NEWWINDOW_FEATURES
Definition: webview.h:2129
wxEVT_WEBVIEW_NEWWINDOW
wxEventType wxEVT_WEBVIEW_NEWWINDOW
Definition: webview.h:2128

Since
  3.3.0

## Public Member Functions
wxWebView * | GetChildWebView ()
| 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.