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

Make IME code early return instead

This commit is contained in:
Adam Scott
2024-11-07 13:24:06 -05:00
parent 87318a2fb7
commit 75bf6df49a

View File

@@ -44,12 +44,15 @@ const GodotIME = {
},
ime_active: function (active) {
if (GodotIME.ime == null) {
return;
}
function focus_timer() {
GodotIME.active = true;
GodotIME.ime.focus();
}
if (GodotIME.ime) {
if (active) {
GodotIME.ime.style.display = 'block';
setInterval(focus_timer, 100);
@@ -58,11 +61,12 @@ const GodotIME = {
GodotConfig.canvas.focus();
GodotIME.active = false;
}
}
},
ime_position: function (x, y) {
if (GodotIME.ime) {
if (GodotIME.ime == null) {
return;
}
const canvas = GodotConfig.canvas;
const rect = canvas.getBoundingClientRect();
const rw = canvas.width / rect.width;
@@ -72,7 +76,6 @@ const GodotIME = {
GodotIME.ime.style.left = `${clx}px`;
GodotIME.ime.style.top = `${cly}px`;
}
},
init: function (ime_cb, key_cb, code, key) {
@@ -84,7 +87,9 @@ const GodotIME = {
evt.preventDefault();
}
function ime_event_cb(event) {
if (GodotIME.ime) {
if (GodotIME.ime == null) {
return;
}
if (event.type === 'compositionstart') {
ime_cb(0, null);
GodotIME.ime.innerHTML = '';
@@ -99,7 +104,6 @@ const GodotIME = {
GodotIME.ime.innerHTML = '';
}
}
}
const ime = document.createElement('div');
ime.className = 'ime';
@@ -133,10 +137,11 @@ const GodotIME = {
},
clear: function () {
if (GodotIME.ime) {
if (GodotIME.ime == null) {
return;
}
GodotIME.ime.remove();
GodotIME.ime = null;
}
},
},
};