godotengine / godotengine/godot

Web: Experimental Virtual Keyboard Does Not Work With LineEdit/TextEdit in SubViewport

Open
#108,355 2 comments 4 reactions 0 assignees View on GitHub
bug platform:web topic:input topic:platforms
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 4.4.1-stable
- Reproducible in 4.5-beta2
- Reproducible in `master` by the time of writing

### System information

iOS WebKit (Safari), Android Blink (Chrome etc)

### Issue description

Any `LineEdit` or `TextEdit` that is located within a `SubViewportContainer > Subviewport` tree will not receive any input in web builds that have `html/experimental_virtual_keyboard=true`.

___

(educated guess from here)

Based on some experiments, it seems the `SubViewport` loses focus (in-engine) when the HTML input gains focus. I assume this is also because the HTLM canvas loses focus.

This would make the following code basically a no-op:

```cpp
//file: /godot/scene/main/viewport.cpp:2777

void Viewport::push_text_input(const String &p_text) {
ERR_MAIN_THREAD_GUARD;
if (gui.subwindow_focused) {
gui.subwindow_focused->push_text_input(p_text);
return;
}

if (gui.key_focus) {
gui.key_focus->call("set_text", p_text);
}
}
```

### Steps to reproduce

* Create empty Project
* Add a `SubViewportContainer > Subviewport > LineEdit` node structure
* Add a Web export template
* Enable `html/experimental_virtual_keyboard=true`
* Run in browser
* Focus the input
* Type with on-screen keyboard
* Nothing is added to the `LineEdit`

### Minimal reproduction project (MRP)

* [Repository](https://github.com/barthy-koeln/godot-repro-web-vk-subviewport)
* [Hosted Preview](https://barthy-koeln.github.io/godot-repro-web-vk-subviewport/)
* [ZIP Archive](https://github.com/user-attachments/files/21091366/godot-repro-web-vk-subviewport--src.zip)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the linked minimal project in a browser using html/experimental_virtual_keyboard=true and a LineEdit or TextEdit inside a SubViewport. Start by reading scene/main/viewport.cpp at Viewport::push_text_input and trace how focus changes when the HTML input receives keyboard input. Done means on-screen keyboard text reaches controls inside the SubViewport in web builds.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, html
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.