Module jls.util.WebView

Provide WebView class.

This class allow to display HTML content in a window. A webview requires a thread to run its own event loop, which is not compatible with the base event loop. This class provide helpers to start webview in a dedicated thread so that the base event loop can be used.

Class WebView

WebView:new (url[, title[, width[, height[, resizable[, debug]]]]]) Creates a new WebView.
webView:loop ([mode]) Processes the webview event loop.
webView:callback (cb) Registers the specified function to be called from the web page.
webView:eval (js) Evaluates the specified JavaScript code in the web page.
webView:fullscreen (fullscreen) Sets the webview fullscreen.
webView:title (title) Sets the webview title.
webView:terminate () Terminates the webview.
WebView:open (url[, title[, width[, height[, resizable[, debug[, sync[, fn[, data]]]]]]]]) Opens the specified URL in a new window.
WebView:toDataUrl (content) Returns an URL representing the specified content.


Class WebView

The WebView class.
WebView:new (url[, title[, width[, height[, resizable[, debug]]]]])
Creates a new WebView.

Parameters:

  • url string the URL of the resource to be viewed.
  • title string the title of the window. (optional)
  • width number the width of the opened window. (optional)
  • height number the height of the opened window. (optional)
  • resizable boolean true if the opened window could be resized. (optional)
  • debug boolean true to enable devtools. (optional)
webView:loop ([mode])
Processes the webview event loop. This function will block. If you need to use the event loop in a callback then use the open function.

Parameters:

  • mode string the loop mode, default, once or nowait. (optional)
webView:callback (cb)
Registers the specified function to be called from the web page. The JavaScript syntax is window.external.invoke("string value");

Parameters:

  • cb function The callback to register.
webView:eval (js)
Evaluates the specified JavaScript code in the web page.

Parameters:

  • js string The JavaScript code to evaluate.
webView:fullscreen (fullscreen)
Sets the webview fullscreen.

Parameters:

  • fullscreen boolean true to switch the webview to fullscreen.
webView:title (title)
Sets the webview title.

Parameters:

  • title string The webview title to set.
webView:terminate ()
Terminates the webview.
WebView:open (url[, title[, width[, height[, resizable[, debug[, sync[, fn[, data]]]]]]]])
Opens the specified URL in a new window. Opening a webview in a dedicated thread may not be supported on all platform.

Parameters:

  • url string the URL of the resource to be viewed.
  • title the title of the window or a table containing the options. (optional)
  • width number the width of the opened window. (optional)
  • height number the height of the opened window. (optional)
  • resizable boolean true if the opened window could be resized. (optional)
  • debug boolean true to enable devtools. (optional)
  • sync boolean true to block until the webview is closed. (optional)
  • fn function a function to be called in the webview context or true to indicate that no callback will be used. (optional)
  • data string the data to be passed to the function as a string. (optional)

Returns:

    jls.lang.Promise a promise that resolve when the webview is available or closed.
WebView:toDataUrl (content)
Returns an URL representing the specified content.

Parameters:

  • content string the HTML content to convert.

Returns:

    string an URL representing the specified content.
generated by LDoc 1.4.6 Last updated 2021-10-23 16:54:16