Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention callback argument count in The JavaScript bridge singleton #10162

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tutorials/platform/web/javascript_bridge.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _doc_web_javascript_bridge:

The JavaScriptBridge Singleton
The JavaScriptBridge singleton
==============================

In web builds, the :ref:`JavaScriptBridge <class_JavaScriptBridge>` singleton
Expand Down Expand Up @@ -93,6 +93,12 @@ Arguments passed by JavaScript to the callback will be passed as a single Godot
js_event.preventDefault()
js_event.returnValue = ''

.. warning::

The number of arguments accepted by the callback method (``_my_callback`` in the above example)
**must** match the number of arguments sent by JavaScript. Otherwise, the callback method will
not be called.

Here is another example that asks the user for the `Notification permission <https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API>`__
and waits asynchronously to deliver a notification if the permission is
granted:
Expand Down