Context objects - Register Object

2025-02-07

To register objects/classes, use set_context_node or set_context_ref.

# if the object inherits from 'Node'
$WebView.set_context_node('some_name', obj)

# if the object inherits from 'RefCounted'
$WebView.set_context_ref('some_name', obj)

Both these functions return a string that contain the schema that was registered, in case you want to debug what exactly got exposed to javascript.

important: use set_context_* before $WebView.load(). Unfortunately, this is a limitation. You cannot add objects after the webview has been loaded.