-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[Web] Add IME input support #79362
[Web] Add IME input support #79362
Conversation
6b3e923
to
f2a2101
Compare
ef4d8b3
to
ced2224
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really nice 🥳
I wonder if this can replace the experimental virtual keyboard support...
I remember I tested the composition events when doing that work, and the browser support was all over the place (missing events, repeated ones, etc) depending on both platform and vendor.
Which OS/browsers did you test?
Would be nice to finalize this for 4.2 :) |
b2bb53d
to
941ffe0
Compare
I have tested current build of your fork, and these are my findings:
2023-12-02.3.33.38-H.264.MP4.mp4
2023-12-02.3.39.03.mov
I am running it on macOS 14.0 Sonoma in case that is relevant. |
Retested it, and it seems to be working only in Firefox. Until Chromium have IME API implemented, we probably won't be able to do anything with it.
Done.
Both should be fixed in the last commit (by applying the same logic as #85458 use). |
Out of curiosity, what APIs are missing from Chromium and Safari? compositionstart/update/end are all available in both engines and it seems like they are the only DOM events used by your PR? I am not familiar enough with Godot's source to dig into C++ code changes you've made (I tried 😭) so I might have missed a lot of things. + Edit: I have tested compositionstart/update/end events on the three browsers with this MDN example. At least with Korean, it seems like all three browsers are outputting the same event logs. |
I think I am onto something, but I am not sure. Apparently, Safari just doesn't render any DOM element inside 2023-12-02.5.17.54.movAfter I just moved the element out of the canvas, it started to behave a bit better. It still is acting weird, but it might be because I am using the older build with the issues I talked above. Same behavior on Arc (Chromium) too. It does not recognize backspace when I did that, so that's new. |
Interesting find, with the |
415cc74
to
7d7bd6e
Compare
How are you so fast? 😂 I was figuring out keyup keydown part and it just got fixed It seems to work perfect so far, except I think it will be better if display mode is fixed instead of absolute. Absolute makes viewport overflow. const ime = document.createElement("div");
ime.className = "ime";
ime.style.background = "none";
ime.style.opacity = 0.0;
ime.style.position = "fixed"; I'd submit PR if it were not just a single word change 😂 but I think it'd be more of a hassle for you to merge PR than just replacing a word. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great 🚀 .
We are missing some cleanup for the added node, this patch adds that.
diff --git a/platform/web/js/libs/library_godot_input.js b/platform/web/js/libs/library_godot_input.js
index ec73f3bdb3..7c070f029d 100644
--- a/platform/web/js/libs/library_godot_input.js
+++ b/platform/web/js/libs/library_godot_input.js
@@ -34,6 +34,7 @@
const GodotIME = {
$GodotIME__deps: ['$GodotRuntime', '$GodotEventListeners'],
+ $GodotIME__postset: 'GodotOS.atexit(function(resolve, reject) { GodotIME.clear(); resolve(); });',
$GodotIME: {
ime: null,
active: false,
@@ -121,6 +122,13 @@ const GodotIME = {
GodotConfig.canvas.parentElement.appendChild(ime);
GodotIME.ime = ime;
},
+
+ clear: function () {
+ if (GodotIME.ime) {
+ GodotIME.ime.remove();
+ GodotIME.ime = null;
+ }
+ },
},
};
mergeInto(LibraryManager.library, GodotIME);
I've also tested this on Android (would be great if someone could test on iOS).
Chrome raise the virtual keyboard, but input doesn't work. This seems to be a problem with chrome on android not emitting composition events with some(?) virtual keyboards.
With Firefox on Android on the other end, some composition events are emitted, and input is received thought it seems to produce unreliable results when auto-completing and auto-correcting.
I don't want virtual keyboards to block this PR since that's not officially supported anyway.
I think this PR still needs some work to at least not break the optional experimental vk support we introduced some time ago which uses a similar approach.
I think we might want to disable IME completely when that option is enabled.
I'll see if I can come up with another patch.
Here's the other patch to only enable IME when experimental VK support is disabled (default) or not available (enabled but does not detect a touchscreen). diff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp
index e9f5577fbe..1b63f28b08 100644
--- a/platform/web/display_server_web.cpp
+++ b/platform/web/display_server_web.cpp
@@ -1137,7 +1137,6 @@ bool DisplayServerWeb::has_feature(Feature p_feature) const {
switch (p_feature) {
//case FEATURE_GLOBAL_MENU:
//case FEATURE_HIDPI:
- case FEATURE_IME:
case FEATURE_ICON:
case FEATURE_CLIPBOARD:
case FEATURE_CURSOR_SHAPE:
@@ -1151,6 +1150,9 @@ bool DisplayServerWeb::has_feature(Feature p_feature) const {
//case FEATURE_WINDOW_TRANSPARENCY:
//case FEATURE_KEEP_SCREEN_ON:
//case FEATURE_ORIENTATION:
+ case FEATURE_IME:
+ // IME does not work with experimental VK support.
+ return godot_js_display_vk_available() == 0;
case FEATURE_VIRTUAL_KEYBOARD:
return godot_js_display_vk_available() != 0;
case FEATURE_TEXT_TO_SPEECH: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work 🚀 !
Thank you very much 🏆 !
Thanks! |
Hi The last letter dissapears in mac. KoreanIMEBugReproduction 2.zip 2024-01-19.8.37.56.mov2024-01-19.8.41.04.mov |
@zerosum-0 please make a separate issue report |
I am Japanese. |
Good morning. |
@MASoftware-es That issue was fixed in 4.3, you should test 4.3-dev5 or later. |
Thanks so much!!El 16 abr 2024 10:27, Rémi Verschelde ***@***.***> escribió:
@MASoftware-es That issue was fixed in 4.3, you should test 4.3-dev5 or later.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@akien-mga |
It could be backported to 3.x if a contributor is interested. The 3.x branch is supported on a best-effort basis, and we already have our hands full with working on improvements for 4.3 (like this PR for example), and bug fixes for 4.2. So I can't make any promises because this is a resourcing question, not a technical issue. |
I am Japanese. Could you please implement [Web] Add IME input support in Godot 3.x ? Web export of Godot 4.x cannot be used for Safari for iPhone. This is a political issue for Japanese people. |
This is |
Implements IME event handling for Web platform.
Bugsquad edit:
2023-07-19.11-23-57.mp4