class Webview::Webview

Defined in:

webview.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(debug, title) #

[View source]

Instance Method Detail

def bind(name : String, fn : JSProc) #

binds a callback function so that it will appear under the given name as a global Javascript function.


[View source]
def destroy #

destroys a WebView and closes the native window.


[View source]
def dispatch(&f : -> ) #

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


[View source]
def eval(js : String) #

evaluates arbitrary Javascript code. Evaluation happens asynchronously, also the result of the expression is ignored. Use RPC bindings if you want to receive notifications about the result of the evaluation.


[View source]
def html=(html : String) #

Set WebView HTML directly


[View source]
def init(js : String) #

injects Javascript code at the initialization of the new page. Every time the WebView will open the new page - this initialization code will be executed. It is guaranteed that code is executed before window.onload.


[View source]
def navigate(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 properlty, WebView will re-encode it for you.


[View source]
def run #

runs the main loop until it's terminated. After this function exists you must destroy the WebView


[View source]
def size(width, height, hint : SizeHints) #

[View source]
def terminate #

Terminate stops the main loop. It is safe to call this function from a background thread.


[View source]
def title=(val) #

[View source]
def unbind(name : String) #

Removes a native Crystal callback that was previously set by #bind.


[View source]
def window #

returns a native window handle pointer. 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.


[View source]