Webview.constructor(parent, [props], [ x ], [ y ], [ width ], [ height ]) constructor


The Webview constructor returns a Webview instance representing a Microsoft Edge Webview2 component.

Parameters

parent

An object that will own the Webview. Parent objects can be any of Window, Groupbox, TabItem and Panel

[props]

An optional table that accepts the following optional fields as keys :

  • "url": string representing the URL that the Webview widget will navigate to once initialized.
  • "options": string representing some custom Chromium command-line arguments (see Chromium commandline options).
.
When running in an embedded executable compiled with rtc, and if the URL starts with file:///, any resource not found locally will be searched inside the embedded content too.

x

An optional number that indicates the Webview horizontal position, in pixels. Zero means the left border of the parent.

y

An optional number that indicates the Webview vertical position, in pixels. Zero means the top border of the parent.

width

An optional number that indicates the Webview width in pixels, autosized to fit text content if omitted.

height

An optional number that indicates the Webview height in pixels, autosized to fit text content if omitted.

A just constructed Webview widget does not mean it is ready to be used.
In particular, during the widget construction process, it can be displayed while it is still initializing.
Once initialized, the Webview widget will throw a Webview.onReady() event, particularly useful to start using the Webview widget.

Example

local ui = require "ui" require "webview" -- create a simple Window local win = ui.Window("Webview.constructor() sample", 320, 200) -- create a Webview on this window local Webview = ui.Webview(win, { url = "https://www.luart.org" }) Webview.align = "all" ui.run(win):wait()