From d8832c2ad601ea8ffc5a7244addad78d7b4c9e4d Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Wed, 19 Mar 2014 21:59:02 +0200 Subject: [PATCH] Fixed Android text input --- src/misc_gui.cpp | 13 +++++++++++++ src/osk_gui.cpp | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 8fbffbda92..4092dcb6dc 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -30,6 +30,10 @@ #include "table/strings.h" +#ifdef __ANDROID__ +#include +#endif + /** Method to open the OSK. */ enum OskActivation { OSKA_DISABLED, ///< The OSK shall not be activated at all. @@ -924,6 +928,15 @@ void QueryString::ClickEditBox(Window *w, Point pt, int wid, int click_count, bo /* Open the OSK window */ ShowOnScreenKeyboard(w, wid); } +#ifdef __ANDROID__ + char text[512]; + strncpy(text, this->text.buf, sizeof(text) - 1); + text[sizeof(text) - 1] = 0; + this->text.DeleteAll(); + SDL_ANDROID_GetScreenKeyboardTextInput(text, sizeof(text) - 1); /* Invoke Android built-in screen keyboard */ + this->text.Assign(text); + w->OnEditboxChanged(wid); +#endif } /** Class for the string query window. */ diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 104f6f4921..52d0d2d7e7 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -22,9 +22,6 @@ #include "table/sprites.h" #include "table/strings.h" -#ifdef __ANDROID__ -#include -#endif char _keyboard_opt[2][OSK_KEYBOARD_ENTRIES * 4 + 1]; static WChar _keyboard[2][OSK_KEYBOARD_ENTRIES]; @@ -417,16 +414,6 @@ void ShowOnScreenKeyboard(Window *parent, int button) GetKeyboardLayout(); new OskWindow(&_osk_desc, parent, button); -#ifdef __ANDROID__ - char text[256]; - SDL_ANDROID_GetScreenKeyboardTextInput(text, sizeof(text) - 1); /* Invoke Android built-in screen keyboard */ - OskWindow *osk = dynamic_cast(FindWindowById(WC_OSK, 0)); - osk->qs->text.Assign(text); - free(osk->orig_str_buf); - osk->orig_str_buf = strdup(osk->qs->text.buf); - - osk->SetDirty(); -#endif } /**