Library

Index

Public Interface

Webviews.WebviewType
Webview(
    size=(1024, 768);
    title="",
    debug=false,
    size_fixed=false,
    unsafe_window_handle=C_NULL,
    enable_webio=true,
    auto_terminate=true
)
Webview(width, height; kwargs...)

Create a new webview instance with size and title.

  • If debug is true, developer tools will be enabled (if the platform supports them).
  • UNSAFE unsafe_window_handle can be an unsafe pointer to the platforms specific native window handle.

If it's non-null - then child WebView is embedded into the given parent window. Otherwise a new window is created. Depending on the platform, a GtkWindow, NSWindow or HWND pointer can be passed here.

  • If enable_webio is true, then WebIO will be enabled.
  • The process will be terminated when all webviews with auto_terminate=true are destroyed.
source
Webviews.Consts.WindowSizeHintType
WindowSizeHint

Enum to specify the window size hint. Values:

  • WEBVIEW_HINT_NONE: Width and height are default size.
  • WEBVIEW_HINT_MIN: Width and height are minimum bounds.
  • WEBVIEW_HINT_MAX: Width and height are maximum bounds.
  • WEBVIEW_HINT_FIXED: Window size can not be changed by a user.
source
Base.runMethod
run(w::Webview)

Runs the webview event loop. Runs the main event loop until it's terminated. After this function exits, the webview is automatically destroyed.

Note: This function will show all webview windows that were created.

source
Webviews.API.terminateFunction
terminate()

Stops the main loop. It is safe to call this function from another other background thread.

source
Webviews.API.destroyFunction
destroy(w::Webview)

Destroys the webview and closes the window along with freeing all internal resources.

source
Webviews.API.dispatchFunction
dispatch(f::Function, w::Webview)

Posts a function to be executed on the main thread. You normally do not need to call this function, unless you want to tweak the native window.

The function f should be callable without arguments.

source
Webviews.API.window_handleFunction
window_handle(w::Webview)

UNSAFE An unsafe pointer to the webviews platform specific native window handle. When using GTK backend the pointer is GtkWindow pointer, when using Cocoa backend the pointer is NSWindow pointer, when using Win32 backend the pointer is HWND pointer.

source
Base.resize!Method
resize!(w::Webview, [size::Tuple{Integer, Integer}]; [hint::WindowSizeHint])

Sets the native window size.

source
Webviews.API.navigate!Function
navigate!(w::Webview, url::AbstractString)

Navigates webview to the given URL. URL may be a data URI, i.e. "data:text/html,<html>...</html>".

source
Webviews.API.html!Function
html!(w::Webview, html::AbstractString)
html!(w::Webview, body)

Set webview HTML directly. If body is not a string, such as a WebIO.Node, it will be converted to HTML first.

source
Webviews.API.init!Function
init(w::Webview, js::AbstractString)

Injects JavaScript code at the initialization of the new page. Every time the webview will open a the new page - this initialization code will be executed. It is guaranteed that code is executed before window.onload.

source
Webviews.API.eval!Function
eval!(w::Webview, js::AbstractString)

Evaluates arbitrary JavaScript code. Evaluation happens asynchronously, also the result of the expression is ignored. Use bind if you want to receive notifications about the results of the evaluation.

source
Webviews.API.bind_rawFunction
bind_raw(f::Function, w::Webview, name::AbstractString)

Binds a callback so that it will appear in the webview with the given name as a global async JavaScript function. Callback receives a seq and req value. The seq parameter is an identifier for using Webviews.return_raw to return a value while the req parameter is a string of an JSON array representing the arguments passed from the JavaScript function call.

The callback function must has the method f(seq::String, req::String).

source
Base.bindMethod
bind(f::Function, w::Webview, name::AbstractString)

Binds a callback so that it will appear in the webview with the given name as a global async JavaScript function. Callback arguments are automatically converted from json to as closely as possible match the arguments in the webview context and the callback automatically converts and returns the return value to the webview.

The callback function must handle a Tuple as its argument.

source
Webviews.API.unbindFunction
unbind(w::Webview, name::AbstractString)

Unbinds a previously bound function freeing its resource and removing it from the webview JavaScript context.

source
Webviews.API.return_rawFunction
return_raw(w::Webview, seq::String, success::Bool, result_or_err)

Allows to return a value from the native binding. Original request pointer must be provided to help internal RPC engine match requests with responses.

source
Webviews.API.set_timeoutFunction
set_timeout(f::Function, w::Webview, interval::Real; [repeat::Bool=false])

Sets a function to be called after the given interval in webview's event loop. If repeat is true, f will be called repeatedly. The function f should be callable without arguments.

This function returns a timer_id::Ptr{Cvoid} which can be used in clear_timeout(webview, timer_id).

source