tutorials/platform/web/javascript_bridge #195
Replies: 1 comment 2 replies
-
REALLY important thing that does not seem to be mentioned, if you do not include an argument in your callback's function, it will not be called by Javascript. Bad: extends Node
var _callback_ref = JavaScriptBridge.create_callback(_my_callback)
# Try to call the callback function every time the user clicks the window
func _ready():
var window = JavaScriptBridge.get_interface("window")
window.onclick = _callback_ref
# This won't ever run because it has no argument!!!
func _my_callback():
JavaScriptBridge.eval("console.log(\"hello!\")") Good: extends Node
var _callback_ref = JavaScriptBridge.create_callback(_my_callback)
# Try to call the callback function every time the user clicks the window
func _ready():
var window = JavaScriptBridge.get_interface("window")
window.onclick = _callback_ref
# This will run because it has an argument
func _my_callback(args):
JavaScriptBridge.eval("console.log(\"hello!\")") |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
tutorials/platform/web/javascript_bridge
In web builds, the JavaScriptBridge singleton allows interaction with JavaScript and web browsers, and can be used to implement some functionalities unique to the web platform. Interacting with Jav...
https://docs.godotengine.org/en/4.3/tutorials/platform/web/javascript_bridge.html
Beta Was this translation helpful? Give feedback.
All reactions