mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 01:21:57 -05:00
Fix first character not getting added and fix backspace not working with web client on-screen keyboard input.
Well at least in the android emulator
This commit is contained in:
parent
52240b0115
commit
1be1f69217
2 changed files with 22 additions and 4 deletions
|
@ -828,7 +828,11 @@ void ChatScreen_Show(void) {
|
|||
|
||||
void ChatScreen_OpenInput(const String* text) {
|
||||
struct ChatScreen* s = &ChatScreen_Instance;
|
||||
#ifdef CC_BUILD_TOUCH
|
||||
s->suppressNextPress = !Input_TouchMode;
|
||||
#else
|
||||
s->suppressNextPress = true;
|
||||
#endif
|
||||
s->grabsInput = true;
|
||||
Camera_CheckFocus();
|
||||
Window_OpenKeyboard();
|
||||
|
|
22
src/Window.c
22
src/Window.c
|
@ -3184,6 +3184,11 @@ void Window_AllocFramebuffer(Bitmap* bmp) { }
|
|||
void Window_DrawFramebuffer(Rect2D r) { }
|
||||
void Window_FreeFramebuffer(Bitmap* bmp) { }
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void SendFakeBackspace(void) {
|
||||
Input_SetPressed(KEY_BACKSPACE, true);
|
||||
Input_SetPressed(KEY_BACKSPACE, false);
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(void) {
|
||||
if (!Input_TouchMode) return;
|
||||
Platform_LogConst("OPEN SESAME");
|
||||
|
@ -3194,12 +3199,21 @@ void Window_OpenKeyboard(void) {
|
|||
elem.setAttribute('style', 'position:absolute; left:0; top:0; width:100%; height:100%; opacity:0.3; resize:none; pointer-events:none;');
|
||||
elem.setAttribute('autocomplete', 'off');
|
||||
elem.setAttribute('autocorrect', 'off');
|
||||
elem.addEventListener("textInput",
|
||||
|
||||
var oldLen = 0|0;
|
||||
elem.addEventListener("input",
|
||||
function(ev) {
|
||||
for (var i = 0; i < ev.data.length; i++) {
|
||||
var code = ev.data.charCodeAt(i);
|
||||
ccall('Window_ProcessKeyChar', 'void', ['number'], [code]);
|
||||
var str = ev.target.value;
|
||||
if (str.length > oldLen) {
|
||||
for (var i = oldLen; i < str.length; i++) {
|
||||
ccall('Window_ProcessKeyChar', 'void', ['number'], [str.charCodeAt(i)]);
|
||||
}
|
||||
} else {
|
||||
for (var i = str.length; i < oldLen; i++) {
|
||||
ccall('SendFakeBackspace', 'void', [], []);
|
||||
}
|
||||
}
|
||||
oldLen = str.length;
|
||||
}, false);
|
||||
|
||||
window.cc_inputElem = elem;
|
||||
|
|
Loading…
Reference in a new issue