IWithPopups

interface

Namespace: Vuplex.WebView

An interface implemented by a webview if it supports opening popups. For detailed examples, please see 3D WebView's PopupDemo and CanvasPopupDemo scenes.

Example

await webViewPrefab.WaitUntilInitialized;
var webViewWithPopups = webViewPrefab.WebView as IWithPopups;
if (webViewWithPopups != null) {
    webViewWithPopups.SetPopupMode(PopupMode.LoadInNewWebView);

    webViewWithPopups.PopupRequested += async (sender, eventArgs) => {
        Debug.Log("Popup opened with URL: " + eventArgs.Url);
        // Create and display a new WebViewPrefab for the popup.
        var popupPrefab = WebViewPrefab.Instantiate(eventArgs.WebView);
        popupPrefab.transform.parent = transform;
        popupPrefab.transform.localPosition = Vector3.zero;
        popupPrefab.transform.localEulerAngles = new Vector3(0, 180, 0);
        await popupPrefab.WaitUntilInitialized();
        popupPrefab.WebView.CloseRequested += (popupWebView, closeEventArgs) => {
            Debug.Log("Closing the popup");
            popupPrefab.Destroy();
        };
    };
}

Summary

Public methods

SetPopupMode

void SetPopupMode(PopupMode popupMode)

Sets how the webview handles popups.

Public events

PopupRequested

EventHandler<PopupRequestedEventArgs> PopupRequested

Indicates that the webview requested a popup.