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

[HTML5] Javascript addEventListener not working ? #55693

Closed
AlexandreHerbreteau opened this issue Dec 7, 2021 · 3 comments
Closed

[HTML5] Javascript addEventListener not working ? #55693

AlexandreHerbreteau opened this issue Dec 7, 2021 · 3 comments

Comments

@AlexandreHerbreteau
Copy link

AlexandreHerbreteau commented Dec 7, 2021

Godot version

3.4.stable

System information

Windows10

Issue description

Hi,

when doing

JavaScript.get_interface("document").addEventListener("visibilitychange", callback)

with

var callback = JavaScript.create_callback(self, "_on_focus_in")

The callback is never called.

Steps to reproduce

Create a new project with a simple Node, an attached script with:

extends Node

var callback = JavaScript.create_callback(self, "_on_focus_in")
func _on_focus_in():
   print("FOCUSSSSSS IN")

func _ready():
	if OS.get_name() == "HTML5":
		JavaScript.get_interface("document").addEventListener("visibilitychange", callback)

Execute in HTML5 target. Open a browser and run the code: The callback is never executed, the message "FOCUSSSS IN" is never printed.

Minimal reproduction project

No response

@Calinou
Copy link
Member

Calinou commented Dec 7, 2021

For the record, this question was cross-posted on the Godot forums.

@nisovin
Copy link

nisovin commented Dec 8, 2021

You need to accept the event parameter in your callback function.

@AlexandreHerbreteau
Copy link
Author

Thanks @nisovin !! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants