For numeric input fields in mobile web client, try to display numeric soft keypad instead of regular one

This commit is contained in:
UnknownShadow200 2020-10-18 15:55:02 +11:00
parent b429750127
commit 3af3d829a1
2 changed files with 14 additions and 4 deletions

View File

@ -2237,6 +2237,7 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
cc_string value; char valueBuffer[STRING_SIZE];
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
struct ButtonWidget* btn = (struct ButtonWidget*)widget;
struct MenuInputDesc* desc;
MenuOptionsScreen_FreeExtHelp(s);
MenuOptionsScreen_FreeInput(s);
@ -2244,15 +2245,19 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
String_InitArray(value, valueBuffer);
btn->GetValue(&value);
desc = &s->descs[s->activeI];
MenuInputWidget_Create(&s->input, 400, &value, &s->descs[s->activeI]);
MenuInputWidget_Create(&s->input, 400, &value, desc);
ButtonWidget_Init(&s->ok, 40, MenuOptionsScreen_OK);
ButtonWidget_Init(&s->Default, 200, MenuOptionsScreen_Default);
s->numWidgets = MENUOPTS_MAX_OPTS + 1 + 3;
MenuOptionsScreen_Layout(screen);
MenuOptionsScreen_RedrawInput(s);
Window_OpenKeyboard(&value, KEYBOARD_TYPE_TEXT);
Window_OpenKeyboard(&value,
(desc->VTABLE == &IntInput_VTABLE || desc->VTABLE == &FloatInput_VTABLE)
? KEYBOARD_TYPE_NUMBER : KEYBOARD_TYPE_TEXT);
}
static void MenuOptionsScreen_OnHacksChanged(void* screen) {

View File

@ -3524,8 +3524,13 @@ void Window_OpenKeyboard(const cc_string* text, int type) {
EM_ASM_({
var elem = window.cc_inputElem;
if (!elem) {
elem = document.createElement('textarea');
elem.setAttribute('style', 'position:absolute; left:0; bottom:0; margin: 0px');
if ($1 == 1) {
elem = document.createElement('input');
elem.setAttribute('inputmode', 'decimal');
} else {
elem = document.createElement('textarea');
}
elem.setAttribute('style', 'position:absolute; left:0; bottom:0; margin: 0px; width: 100%');
elem.value = UTF8ToString($0);
elem.addEventListener('input',