12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <class name="JavaScript" inherits="Object" version="3.4">
- <brief_description>
- Singleton that connects the engine with the browser's JavaScript context in HTML5 export.
- </brief_description>
- <description>
- The JavaScript singleton is implemented only in the HTML5 export. It's used to access the browser's JavaScript context. This allows interaction with embedding pages or calling third-party JavaScript APIs.
- [b]Note:[/b] This singleton can be disabled at build-time to improve security. By default, the JavaScript singleton is enabled. Official export templates also have the JavaScript singleton enabled. See [url=https://docs.godotengine.org/en/3.3/development/compiling/compiling_for_web.html]Compiling for the Web[/url] in the documentation for more information.
- </description>
- <tutorials>
- <link>https://docs.godotengine.org/en/3.3/getting_started/workflow/export/exporting_for_web.html#calling-javascript-from-script</link>
- </tutorials>
- <methods>
- <method name="create_callback">
- <return type="JavaScriptObject">
- </return>
- <argument index="0" name="object" type="Object">
- </argument>
- <argument index="1" name="method" type="String">
- </argument>
- <description>
- Creates a reference to a script function that can be used as a callback by JavaScript. The reference must be kept until the callback happens, or it won't be called at all. See [JavaScriptObject] for usage.
- </description>
- </method>
- <method name="create_object" qualifiers="vararg">
- <return type="Variant">
- </return>
- <argument index="0" name="object" type="String">
- </argument>
- <description>
- Creates a new JavaScript object using the [code]new[/code] constructor. The [code]object[/code] must a valid property of the JavaScript [code]window[/code]. See [JavaScriptObject] for usage.
- </description>
- </method>
- <method name="eval">
- <return type="Variant">
- </return>
- <argument index="0" name="code" type="String">
- </argument>
- <argument index="1" name="use_global_execution_context" type="bool" default="false">
- </argument>
- <description>
- Execute the string [code]code[/code] as JavaScript code within the browser window. This is a call to the actual global JavaScript function [code]eval()[/code].
- If [code]use_global_execution_context[/code] is [code]true[/code], the code will be evaluated in the global execution context. Otherwise, it is evaluated in the execution context of a function within the engine's runtime environment.
- </description>
- </method>
- <method name="get_interface">
- <return type="JavaScriptObject">
- </return>
- <argument index="0" name="interface" type="String">
- </argument>
- <description>
- Returns an interface to a JavaScript object that can be used by scripts. The [code]interface[/code] must be a valid property of the JavaScript [code]window[/code]. The callback must accept a single [Array] argument, which will contain the JavaScript [code]arguments[/code]. See [JavaScriptObject] for usage.
- </description>
- </method>
- </methods>
- <constants>
- </constants>
- </class>
|