XU XUv0.13.1
中文

UI / WIDGETS / Embedded content

WebView

Embed web content inside a native interface

Run the Xu example

The example executes in the browser using the Xu/WASM runtime.

What to try

Switch between embedded preview pages.

Usage notes

Native WebView requires a desktop host and has its own loading, focus and disposal lifecycle. The browser preview is not an operating-system WebView2 or other native host.

Create through Screen

The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.

Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.

#ui/widgets

fn configure(screen $&widgets.Screen) int {
    id := screen.webview() or >>
    screen.place(id,24.0,24.0,320.0,80.0) or >>
    << id
}

($&Screen) webview

XuAPI
pub fn (s $&Screen) webview() int

Purpose

Create WebView in Screen and return the component node ID; throw on creation failure.

Parameters

s $&Screen
The Screen instance used by this call (exclusive borrow).

Returns

int — component node ID for place and other Screen methods.

Placement, state and events

The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.

Action · Styles · UI lifecycle and styling guide

Screen.place · Screen.set_enabled · Screen.set_visible

Standalone control object API

These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.

Complete native example

Component Workshop · Back to Widgets