mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
Currently including `zh_CN` and `es` which both have very high completion ratios. Others will be added once they reach a significant percentage too. These RST files will be used by godot-docs in place of its `classes` folder after we sync with https://github.com/godotengine/godot-docs/pull/5458. The update workflow is manual for now (example for `zh_CN`): - Build `godotengine/godot` in the branch we currently track (now `3.x`) - Run `godot --doctool -l zh_CN` - Run `cd doc && make rst LANGARG=zh_CN` - Copy `doc/_build/rst/*` to `classes/zh_CN/` here - Make sure to have `classes/zh_CN/index.rst` copied from `docs/classes`
54 lines
2.2 KiB
ReStructuredText
54 lines
2.2 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the JavaScriptObject.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_JavaScriptObject:
|
|
|
|
JavaScriptObject
|
|
================
|
|
|
|
**Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
|
|
|
|
A wrapper class for native JavaScript objects.
|
|
|
|
Descripción
|
|
----------------------
|
|
|
|
JavaScriptObject is used to interact with JavaScript objects retrieved or created via :ref:`JavaScript.get_interface<class_JavaScript_method_get_interface>`, :ref:`JavaScript.create_object<class_JavaScript_method_create_object>`, or :ref:`JavaScript.create_callback<class_JavaScript_method_create_callback>`.
|
|
|
|
Example:
|
|
|
|
::
|
|
|
|
extends Node
|
|
|
|
var _my_js_callback = JavaScript.create_callback(self, "myCallback") # This reference must be kept
|
|
var console = JavaScript.get_interface("console")
|
|
|
|
func _init():
|
|
var buf = JavaScript.create_object("ArrayBuffer", 10) # new ArrayBuffer(10)
|
|
print(buf) # prints [JavaScriptObject:OBJECT_ID]
|
|
var uint8arr = JavaScript.create_object("Uint8Array", buf) # new Uint8Array(buf)
|
|
uint8arr[1] = 255
|
|
prints(uint8arr[1], uint8arr.byteLength) # prints 255 10
|
|
console.log(uint8arr) # prints in browser console "Uint8Array(10) [ 0, 255, 0, 0, 0, 0, 0, 0, 0, 0 ]"
|
|
|
|
# Equivalent of JavaScript: Array.from(uint8arr).forEach(myCallback)
|
|
JavaScript.get_interface("Array").from(uint8arr).forEach(_my_js_callback)
|
|
|
|
func myCallback(args):
|
|
# Will be called with the parameters passed to the "forEach" callback
|
|
# [0, 0, [JavaScriptObject:1173]]
|
|
# [255, 1, [JavaScriptObject:1173]]
|
|
# ...
|
|
# [0, 9, [JavaScriptObject:1180]]
|
|
print(args)
|
|
|
|
\ **Note:** Only available in the HTML5 platform.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|