Fix Text Auto-Complete On Android

This commit is contained in:
TheBrokenRail
2023-11-05 15:23:40 -05:00
committed by iProgramInCpp
parent d4a100825b
commit 20790755d1
2 changed files with 13 additions and 8 deletions

View File

@@ -138,6 +138,12 @@ static void handle_events()
break; break;
} }
// Text Editing
if (event.key.keysym.sym == SDLK_BACKSPACE && event.key.state == SDL_PRESSED)
{
g_pApp->handleCharInput('\b');
}
// Normal Key Press // Normal Key Press
Keyboard::feed(AppPlatform_sdl_base::GetKeyState(event), TranslateSDLKeyCodeToVirtual(event.key.keysym.sym)); Keyboard::feed(AppPlatform_sdl_base::GetKeyState(event), TranslateSDLKeyCodeToVirtual(event.key.keysym.sym));
if (event.key.keysym.sym == SDLK_LSHIFT || event.key.keysym.sym == SDLK_RSHIFT) if (event.key.keysym.sym == SDLK_LSHIFT || event.key.keysym.sym == SDLK_RSHIFT)
@@ -191,10 +197,14 @@ static void handle_events()
{ {
if (g_pApp != nullptr) if (g_pApp != nullptr)
{ {
char x = event.text.text[0]; size_t length = strlen(event.text.text);
if (x >= ' ' && x <= '~') for (size_t i = 0; i < length; i++)
{ {
g_pApp->handleCharInput(x); char x = event.text.text[i];
if (x >= ' ' && x <= '~')
{
g_pApp->handleCharInput(x);
}
} }
} }
break; break;

View File

@@ -144,11 +144,6 @@ void TextInputBox::keyPressed(Minecraft* minecraft, int key)
case AKEYCODE_ARROW_RIGHT: case AKEYCODE_ARROW_RIGHT:
chr = '\003'; chr = '\003';
break; break;
#ifdef USE_SDL
case AKEYCODE_DEL:
chr = '\b';
break;
#endif
} }
#endif #endif