Platforms to show: All Mac Windows Linux Cross-Platform
Back to WebView2ControlMBS control.
WebView2ControlMBS.AddScriptToExecuteOnDocumentCreatedCompleted(JavaScript as String, ErrorCode as Integer, ID as String, Tag as Variant)
Function:
The event to report that AddScriptToExecuteOnDocumentCreated is done and provide the ID.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
WebView2ControlMBS.CapturePreviewCompleted(ImageFormat as Integer, ErrorCode as Integer, PictureData as String)
Function:
The event called when CapturePreview call is done.
Notes:
We pass you the image data as a string, so you can e.g. write it to a PNG or JPEG file.
Otherwise ErrorCode tells you the reason for the error.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes:
We pass you the image data as a string, so you can e.g. write it to a PNG or JPEG file.
Otherwise ErrorCode tells you the reason for the error.
WebView2ControlMBS.Close
Function:
The control is about to close.
In Xojo version 2021r3 and newer this event is named Closing.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
The control is about to close.
In Xojo version 2021r3 and newer this event is named Closing.
WebView2ControlMBS.Closing
Function:
The control is about to close.
In older Xojo versions, this event is named Close.
Type | Topic | Version |
event | WebView2 | 20.5 |
The control is about to close.
In older Xojo versions, this event is named Close.
WebView2ControlMBS.Configure
Function:
The event called while initializing, where you can apply properties just before plugin reads them.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
WebView2ControlMBS.ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) as Boolean
Function:
This event is called when it is appropriate to display a contextual menu for the control.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 22.1 | ❌ No | ✅ Yes | ❌ No | ❌ No |
WebView2ControlMBS.ContainsFullScreenElementChanged
Function:
ContainsFullScreenElementChanged fires when the ContainsFullScreenElement property changes.
Notes: This means that an HTML element inside the WebView is entering fullscreen to the size of the WebView or leaving fullscreen. This event is useful when, for example, a video element requests to go fullscreen. The listener of ContainsFullScreenElementChanged can then resize the WebView in response.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes: This means that an HTML element inside the WebView is entering fullscreen to the size of the WebView or leaving fullscreen. This event is useful when, for example, a video element requests to go fullscreen. The listener of ContainsFullScreenElementChanged can then resize the WebView in response.
WebView2ControlMBS.ContentLoading(isErrorPage as Boolean, NavigationID as UInt64)
Function:
The content loading event.d
Notes: ContentLoading fires before any content is loaded, including scripts added with AddScriptToExecuteOnDocumentCreated. ContentLoading will not fire if a same page navigation occurs (such as through fragment navigations or history.pushState navigations). This follows the NavigationStarting and SourceChanged events and precedes the HistoryChanged and NavigationCompleted events.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes: ContentLoading fires before any content is loaded, including scripts added with AddScriptToExecuteOnDocumentCreated. ContentLoading will not fire if a same page navigation occurs (such as through fragment navigations or history.pushState navigations). This follows the NavigationStarting and SourceChanged events and precedes the HistoryChanged and NavigationCompleted events.
WebView2ControlMBS.ContextualMenuAction(hitItem as MenuItem) as Boolean
Function:
Called when a menuitem is choosen.
Notes: This allows the control to react on its relevant menu items. Please return true if you handled it or false to give others a chance.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 22.1 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes: This allows the control to react on its relevant menu items. Please return true if you handled it or false to give others a chance.
WebView2ControlMBS.DocumentTitleChanged
Function:
The event to report a document title change.
Notes: DocumentTitleChanged fires when the DocumentTitle property of the WebView changes and may fire before or after the NavigationCompleted event.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes: DocumentTitleChanged fires when the DocumentTitle property of the WebView changes and may fire before or after the NavigationCompleted event.
WebView2ControlMBS.EnableMenuItems
Function:
The event where you can enable menu items.
In Xojo version 2021r3 and newer this event is named MenuBarSelected.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 22.1 | ❌ No | ✅ Yes | ❌ No | ❌ No |
The event where you can enable menu items.
In Xojo version 2021r3 and newer this event is named MenuBarSelected.
WebView2ControlMBS.ExecuteScriptCompleted(JavaScript as String, ErrorCode as Integer, resultObjectAsJson as String, Tag as Variant)
Function:
The event to report ExecuteScript method is done.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
WebView2ControlMBS.FocusLost
Function:
LostFocus fires when WebView lost focus.
In older Xojo versions, this event is named LostFocus.
Notes: In the case where MoveFocusRequested event is fired, the focus is still on WebView when MoveFocusRequested event fires. LostFocus only fires afterwards when app's code or default action of MoveFocusRequested event set focus away from WebView.
Type | Topic | Version |
event | WebView2 | 20.5 |
LostFocus fires when WebView lost focus.
In older Xojo versions, this event is named LostFocus.
Notes: In the case where MoveFocusRequested event is fired, the focus is still on WebView when MoveFocusRequested event fires. LostFocus only fires afterwards when app's code or default action of MoveFocusRequested event set focus away from WebView.
WebView2ControlMBS.FocusReceived
Function:
GotFocus fires when WebView got focus.
In older Xojo versions, this event is named GotFocus.
Type | Topic | Version |
event | WebView2 | 20.5 |
GotFocus fires when WebView got focus.
In older Xojo versions, this event is named GotFocus.
WebView2ControlMBS.FrameNavigationCompleted(isSuccess as Boolean, ErrorStatus as Integer, NavigationID as UInt64)
Function:
FrameNavigationCompleted fires when a child frame has completely loaded (body.onload has fired) or loading stopped with error.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
WebView2ControlMBS.FrameNavigationStarting(URL as String, IsUserInitiated as Boolean, IsRedirected as Boolean, NavigationID as UInt64) as Boolean
Function:
FrameNavigationStarting fires when a child frame in the WebView requests permission to navigate to a different URI. This will fire for redirects as well.
Notes:
Corresponding navigations can be blocked until the event handler returns.
Return true to block the request.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes:
Corresponding navigations can be blocked until the event handler returns.
Return true to block the request.
WebView2ControlMBS.GotFocus
Function:
GotFocus fires when WebView got focus.
In Xojo version 2021r3 and newer this event is named FocusReceived.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
GotFocus fires when WebView got focus.
In Xojo version 2021r3 and newer this event is named FocusReceived.
WebView2ControlMBS.HistoryChanged
Function:
The event to report history change.
Notes: HistoryChanged listens to the change of navigation history for the top level document. Use HistoryChanged to check if CanGoBack/CanGoForward value has changed. HistoryChanged also fires for using GoBack/GoForward. HistoryChanged fires after SourceChanged and ContentLoading.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes: HistoryChanged listens to the change of navigation history for the top level document. Use HistoryChanged to check if CanGoBack/CanGoForward value has changed. HistoryChanged also fires for using GoBack/GoForward. HistoryChanged fires after SourceChanged and ContentLoading.
WebView2ControlMBS.LostFocus
Function:
LostFocus fires when WebView lost focus.
In Xojo version 2021r3 and newer this event is named FocusLost.
Notes: In the case where MoveFocusRequested event is fired, the focus is still on WebView when MoveFocusRequested event fires. LostFocus only fires afterwards when app's code or default action of MoveFocusRequested event set focus away from WebView.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
LostFocus fires when WebView lost focus.
In Xojo version 2021r3 and newer this event is named FocusLost.
Notes: In the case where MoveFocusRequested event is fired, the focus is still on WebView when MoveFocusRequested event fires. LostFocus only fires afterwards when app's code or default action of MoveFocusRequested event set focus away from WebView.
WebView2ControlMBS.MenuBarSelected
Function:
The event where you can enable menu items.
In older Xojo versions, this event is named EnableMenuItems.
Type | Topic | Version |
event | WebView2 | 22.1 |
The event where you can enable menu items.
In older Xojo versions, this event is named EnableMenuItems.
WebView2ControlMBS.NavigationCompleted(isSuccess as Boolean, ErrorStatus as Integer, NavigationID as UInt64)
Function:
The event to report a navigation action completed.
Notes:
NavigationCompleted fires when the WebView has completely loaded (body.onload has fired) or loading stopped with error.
Please don't process directly here, but maybe call a method with timer.CallLater to do processing like using HTMLText or PlainText functions.
Like the DocumentCompleted event in Xojo.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes:
NavigationCompleted fires when the WebView has completely loaded (body.onload has fired) or loading stopped with error.
Please don't process directly here, but maybe call a method with timer.CallLater to do processing like using HTMLText or PlainText functions.
Like the DocumentCompleted event in Xojo.
WebView2ControlMBS.NavigationStarting(URL as String, IsUserInitiated as Boolean, IsRedirected as Boolean, NavigationID as UInt64) as Boolean
Function:
The event to report a navigation action.
Notes:
NavigationStarting fires when the WebView main frame is requesting permission to navigate to a different URI. This will fire for redirects as well.
Corresponding navigations can be blocked until the event handler returns.
Return true to cancel it like Xojo's CancelLoad event.
This event is great to check the URL. If you like to block it, you may just return true. If the user initiated the request, you may instead want to load a warning page. Also check the URL and decide whether to turn scripting on or off.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes:
NavigationStarting fires when the WebView main frame is requesting permission to navigate to a different URI. This will fire for redirects as well.
Corresponding navigations can be blocked until the event handler returns.
Return true to cancel it like Xojo's CancelLoad event.
This event is great to check the URL. If you like to block it, you may just return true. If the user initiated the request, you may instead want to load a warning page. Also check the URL and decide whether to turn scripting on or off.
WebView2ControlMBS.NewWindowRequested(URL as String, IsUserInitiated as Boolean, WindowFeatures as WebView2WindowFeaturesMBS, byref NewWindow as Variant) as Boolean
Function:
The event called when a new window needs to be opened.
Notes:
Return true to indicate you handled the event.
If you create a new window with a WebView2ControlMBS (or DesktopWebView2ControlMBS), you can put it in NewWindow property.
IsUserInitiated:
True when the new window request was initiated through a user gesture.
Examples of user initiated requests are:
Selecting an anchor tag with target
Programmatic window open from a script that directly run as a result of user interaction such as via onclick handlers.
Non-user initiated requests are programmatic window opens from a script that are not directly triggered by user interaction, such as those that run while loading a new page or via timers. The Microsoft Edge popup blocker is disabled for WebView so the app is able to use this flag to block non-user initiated popups.
URL: The target uri of the new window requested.
NewWindow: Set the new control to use.
If the NewWindow is set, the top-level window returns as the opened WindowProxy. The NewWindow property should be set to a control that has not been navigated previously. Don't use methods that cause navigation or interact with the DOM on this web view. Setting event handlers, changing Settings properties, or other methods are fine to call. Changes to settings should be made before NewWindow is called to ensure that those settings take effect for the newly setup WebView. Once the NewWindow is set the underlying web contents of this CoreWebView2 will be replaced and navigated as appropriate for the new window. After setting new window it cannot be changed and error will be return otherwise.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 21.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes:
Return true to indicate you handled the event.
If you create a new window with a WebView2ControlMBS (or DesktopWebView2ControlMBS), you can put it in NewWindow property.
IsUserInitiated:
True when the new window request was initiated through a user gesture.
Examples of user initiated requests are:
Selecting an anchor tag with target
Programmatic window open from a script that directly run as a result of user interaction such as via onclick handlers.
Non-user initiated requests are programmatic window opens from a script that are not directly triggered by user interaction, such as those that run while loading a new page or via timers. The Microsoft Edge popup blocker is disabled for WebView so the app is able to use this flag to block non-user initiated popups.
URL: The target uri of the new window requested.
NewWindow: Set the new control to use.
If the NewWindow is set, the top-level window returns as the opened WindowProxy. The NewWindow property should be set to a control that has not been navigated previously. Don't use methods that cause navigation or interact with the DOM on this web view. Setting event handlers, changing Settings properties, or other methods are fine to call. Changes to settings should be made before NewWindow is called to ensure that those settings take effect for the newly setup WebView. Once the NewWindow is set the underlying web contents of this CoreWebView2 will be replaced and navigated as appropriate for the new window. After setting new window it cannot be changed and error will be return otherwise.
WebView2ControlMBS.Open
Function:
The control is about to was created and you can initialize it.
In Xojo version 2021r3 and newer this event is named Opening.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
The control is about to was created and you can initialize it.
In Xojo version 2021r3 and newer this event is named Opening.
WebView2ControlMBS.Opened
Function:
The event called when browser initialization is done.
Notes:
Typical event flow is like this:
Opened is called a few milliseconds later.
If you load an URL, the events happen like this:
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes:
Typical event flow is like this:
- Configure
- Open
- Window.Open
- Opened
Opened is called a few milliseconds later.
If you load an URL, the events happen like this:
- NavigationStarting
- SourceChanged
- ContentLoading
- HistoryChanged
- DocumentTitleChanged
- NavigationCompleted
WebView2ControlMBS.Opening
Function:
The control is about to was created and you can initialize it.
In older Xojo versions, this event is named Open.
Type | Topic | Version |
event | WebView2 | 20.5 |
The control is about to was created and you can initialize it.
In older Xojo versions, this event is named Open.
WebView2ControlMBS.PermissionRequested(URL as String, PermissionKind as Integer, IsUserInitiated as Boolean, byref State as Integer)
Function:
The event to query permissions from user.
Notes:
PermissionRequested fires when content in a WebView requests permission to access some privileged resources.
If a deferral is not taken on the event args, the subsequent scripts can be blocked until the event handler returns. If a deferral is taken, then the scripts are blocked until the deferral is completed.
URL: The origin of the web content that requests the permission.
PermissionKind: The type of the permission that is requested.
IsUserInitiated: True when the permission request was initiated through a user gesture.
State: The status of a permission request, i.e.
Please assign State the answer you like to provide.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes:
PermissionRequested fires when content in a WebView requests permission to access some privileged resources.
If a deferral is not taken on the event args, the subsequent scripts can be blocked until the event handler returns. If a deferral is taken, then the scripts are blocked until the deferral is completed.
URL: The origin of the web content that requests the permission.
PermissionKind: The type of the permission that is requested.
IsUserInitiated: True when the permission request was initiated through a user gesture.
State: The status of a permission request, i.e.
Please assign State the answer you like to provide.
WebView2ControlMBS.PrintCompleted(Path as String, errorCode as Integer, isSuccessful as boolean)
Function:
Receives the result of the PrintToPdf method.
Notes: If the print to PDF operation succeeds, isSuccessful is true. Otherwise, if the operation failed, isSuccessful is set to false. An invalid path returns E_INVALIDARG in errorCode.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 23.1 | ❌ No | ✅ Yes | ❌ No | ❌ No |
Notes: If the print to PDF operation succeeds, isSuccessful is true. Otherwise, if the operation failed, isSuccessful is set to false. An invalid path returns E_INVALIDARG in errorCode.
WebView2ControlMBS.ProcessFailed(processFailedKind as Integer)
Function:
ProcessFailed fires when a WebView process is terminated unexpectedly or becomes unresponsive.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
event | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No |
The items on this page are in the following plugins: MBS WinFrameworks Plugin.
