Package 

Interface WebviewJNA.WebviewLibrary

    • Constructor Detail

    • Method Detail

      • webview_create

         abstract Pointer webview_create(Integer debug, Pointer window)

        Creates a new webview instance.

        If debug is non-zero - developer tools will be enabled (if the platform supports them). Window parameter can be a pointer to the 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.

      • webview_run

         abstract Unit webview_run(Pointer webview)

        Runs the main loop until it's terminated.

        After this function exits - you must destroy the webview.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
      • webview_terminate

         abstract Unit webview_terminate(Pointer webview)

        Stops the main loop.

        It is safe to call this function from another other background thread.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
      • webview_dispatch

        @Deprecated(message = "You normally do not need it, unless you want to tweak the native window") abstract Unit webview_dispatch(Pointer webview, WebviewJNA.WebviewLibrary.webview_dispatch_fn_callback fn, Pointer args)

        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.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        fn - the callback
      • webview_get_window

        @Deprecated(message = "Not suggested to use") abstract Pointer webview_get_window(Pointer webview)

        Returns a native window handle pointer.

        Not suggested to use. 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.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
      • webview_set_title

         abstract Unit webview_set_title(Pointer webview, String title)

        Updates the title of the native window.

        Must be called from the UI thread.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        title - the new title
      • webview_set_size

         abstract Unit webview_set_size(Pointer webview, Integer width, Integer height, Integer hints)

        Updates the size of the native window.

        Accepts a WEBVIEW_HINT

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        hints - can be one of WEBVIEW_HINT_NONE, WEBVIEW_HINT_MIN, WEBVIEW_HINT_MAX or WEBVIEW_HINT_FIXED
      • webview_navigate

         abstract Unit webview_navigate(Pointer webview, String url)

        Navigates webview to the given URL

        URL may be a data URI, i.e. "data:text/text,...". It is often ok not to url-encode it properly, webview will re-encode it for you.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        url - the URL or URI
      • webview_set_html

         abstract Unit webview_set_html(Pointer webview, String html)

        Set webview HTML directly.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        html - the HTML content
      • webview_init

         abstract Unit webview_init(Pointer webview, String js)

        Injects JavaScript code at the initialization of the new page.

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

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        js - the JS code
      • webview_eval

         abstract Unit webview_eval(Pointer webview, String js)

        Evaluates arbitrary JavaScript code.

        Evaluation happens asynchronously, also the result of the expression is ignored. Use the webview_bind function if you want to receive notifications about the results of the evaluation.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        js - the JS code
      • webview_bind

         abstract Unit webview_bind(Pointer webview, String name, WebviewJNA.WebviewLibrary.webview_bind_fn_callback callback, Pointer arg)

        Binds a native Kotlin/Java callback so that it will appear under the given name as a global JavaScript function.

        Callback receives a request string. Request string is a JSON array of all the arguments passed to the JavaScript function. Internally it uses webview_init.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        name - the name of the global JavaScript function
        callback - the Kotlin/Java callback function wrapper in an interface, use webview_return to response to the JS request.
      • webview_unbind

         abstract Unit webview_unbind(Pointer webview, String name)

        Removes a Kotlin/Java callback that was previously set by webview_bind.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        name - the name of JS function used in webview_bind
      • webview_return

         abstract Unit webview_return(Pointer webview, String seq, Integer status, String result)

        Allows to return a value from the Kotlin/Java binding.

        Original request pointer must be provided to help internal RPC engine match requests with responses. It is similar to webview::resolve in C++ version.

        Parameters:
        webview - the handle of webview, usually returned by webview_create
        seq - the id of request to response
        status - If status is zero - result is expected to be a valid JSON result value.
        result - the JSON result value to response