Async Android text input
This commit is contained in:
@@ -46,6 +46,8 @@ enum OskActivation {
|
|||||||
OSKA_IMMEDIATELY, ///< Focusing click already opens OSK.
|
OSKA_IMMEDIATELY, ///< Focusing click already opens OSK.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char _android_text_input[512];
|
||||||
|
|
||||||
|
|
||||||
static const NWidgetPart _nested_land_info_widgets[] = {
|
static const NWidgetPart _nested_land_info_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
@@ -772,6 +774,14 @@ void QueryString::HandleEditBox(Window *w, int wid)
|
|||||||
/* For the OSK also invalidate the parent window */
|
/* For the OSK also invalidate the parent window */
|
||||||
if (w->window_class == WC_OSK) w->InvalidateData();
|
if (w->window_class == WC_OSK) w->InvalidateData();
|
||||||
}
|
}
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
if (SDL_IsScreenKeyboardShown(NULL)) {
|
||||||
|
if (SDL_ANDROID_GetScreenKeyboardTextInputAsync(_android_text_input, sizeof(_android_text_input)) == SDL_ANDROID_TEXTINPUT_ASYNC_FINISHED) {
|
||||||
|
this->text.Assign(_android_text_input);
|
||||||
|
w->OnEditboxChanged(wid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryString::DrawEditBox(const Window *w, int wid) const
|
void QueryString::DrawEditBox(const Window *w, int wid) const
|
||||||
@@ -953,15 +963,9 @@ void QueryString::ClickEditBox(Window *w, Point pt, int wid, int click_count, bo
|
|||||||
ShowOnScreenKeyboard(w, wid);
|
ShowOnScreenKeyboard(w, wid);
|
||||||
}
|
}
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
char text[512];
|
strecpy(_android_text_input, this->text.buf, lastof(_android_text_input));
|
||||||
strecpy(text, this->text.buf, lastof(text));
|
|
||||||
this->text.DeleteAll();
|
this->text.DeleteAll();
|
||||||
SDL_ANDROID_ToggleScreenKeyboardTextInput(text); // Invoke Android built-in screen keyboard, this will not block
|
SDL_ANDROID_GetScreenKeyboardTextInputAsync(_android_text_input, sizeof(_android_text_input));
|
||||||
/*
|
|
||||||
SDL_ANDROID_GetScreenKeyboardTextInput(text, sizeof(text) - 1); // Invoke Android built-in screen keyboard, this will block
|
|
||||||
this->text.Assign(text);
|
|
||||||
w->OnEditboxChanged(wid);
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user