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 exported game in iframe loses keyboard input after unfocus and attempt to refocus #55017

Closed
ShouxTech opened this issue Nov 16, 2021 · 8 comments · Fixed by #55111
Closed

Comments

@ShouxTech
Copy link

Godot version

v3.4-stable_mono

System information

Windows 10, GLES2

Issue description

The canvas fails to regain capture input after clicking out of the iframe that it's located in. It only works the first time when you have 'Focus Canvas On Start' enabled. When the page loads, your input is captured and everything works fine but if you click off the iframe that the game is located in and try to click back in, your keyboard input doesn't work. Clicks work but keyboard input doesn't.

Attached is a video trying to show this.

2021-11-15.20-10-18.mp4

Steps to reproduce

I have created a very simple project that displays a label when you press E. If you run it in Godot editor, it works fine.

To run the exported game, go into /export and if you have python 3.x installed, run python -m http.server or py -3 -m http.server

Go to localhost://[the port that came from python output] in your browser and try to press E. It works. Now click out of the iframe and click back in it. It doesn't work.

The main script is located in res://Notification.cs

Minimal reproduction project

InputLogger.zip

@DoctorPoptart
Copy link

Honestly this error is probably your fault.

@ShouxTech
Copy link
Author

ShouxTech commented Nov 16, 2021

One way to fix this is to go into game.js (the file with the Engine class) and remove every instance of evt.preventDefault() using ctrl + h

@Calinou
Copy link
Member

Calinou commented Nov 16, 2021

cc @Faless

@Faless
Copy link
Collaborator

Faless commented Nov 16, 2021

Is it working as expected in 3.3?

@ShouxTech
Copy link
Author

Is it working as expected in 3.3?

Yes. It works as intended. I installed 3.3 from here and remade the InputLogger (attached zip) and exported the project in HTML5 and keyboard input works again each time you refocus the iframe.

InputLogger2.zip

@Alexey-aka-sultan
Copy link

Sorry for the Google translator. Not only in C#. I observe the same bug in my game written in gdscript.

@Faless
Copy link
Collaborator

Faless commented Nov 17, 2021

Yep, this is likely a regression from #52812

@akien-mga akien-mga added this to the 3.5 milestone Nov 17, 2021
@ShouxTech ShouxTech changed the title C# HTML5 exported game in iframe loses keyboard input after unfocus and attempt to refocus HTML5 exported game in iframe loses keyboard input after unfocus and attempt to refocus Nov 17, 2021
@JasonTable
Copy link

I noticed that in Firefox, if the game has a clickable button to capture the cursor, the cursor gets stuck captured and pressing escape wont free it like it normally should. However F5 refreshes the page and frees it. That's probably more of a Firefox bug though.

RichoM added a commit to RichoM/Purple-vs-Yellow that referenced this issue Dec 14, 2021
I had to export with v3.3.3 because of a regression bug in 3.4 (godotengine/godot#55017).
This means we lose the PWA features but it's okay because it didn't really work that well. So I might need to export for android anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants