1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

[Web IME] Fix suggestion window position in Chromium based browsers.

This commit is contained in:
bruvzg
2024-05-08 10:28:55 +03:00
parent cff016d6dd
commit 99d6f32918
3 changed files with 40 additions and 23 deletions

View File

@@ -63,8 +63,15 @@ const GodotIME = {
ime_position: function (x, y) {
if (GodotIME.ime) {
GodotIME.ime.style.left = `${x}px`;
GodotIME.ime.style.top = `${y}px`;
const canvas = GodotConfig.canvas;
const rect = canvas.getBoundingClientRect();
const rw = canvas.width / rect.width;
const rh = canvas.height / rect.height;
const clx = (x / rw) + rect.x;
const cly = (y / rh) + rect.y;
GodotIME.ime.style.left = `${clx}px`;
GodotIME.ime.style.top = `${cly}px`;
}
},
@@ -99,10 +106,12 @@ const GodotIME = {
ime.style.background = 'none';
ime.style.opacity = 0.0;
ime.style.position = 'fixed';
ime.style.textAlign = 'left';
ime.style.fontSize = '1px';
ime.style.left = '0px';
ime.style.top = '0px';
ime.style.width = '2px';
ime.style.height = '2px';
ime.style.width = '100%';
ime.style.height = '40px';
ime.style.display = 'none';
ime.contentEditable = 'true';