mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 15:28:21 -04:00
Synchronise html input with initial text of text input widgets
This way backspacing in gen level/env settings etc works properly
This commit is contained in:
parent
b9dd22b41c
commit
d11038d6e9
@ -883,6 +883,7 @@ static void EditHotkeyScreen_Init(void* screen) {
|
||||
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -35);
|
||||
Menu_Back(s, 5, &s->cancel, Menu_SwitchHotkeys);
|
||||
Window_OpenKeyboard();
|
||||
Window_SetKeyboardText(&text);
|
||||
}
|
||||
|
||||
static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
|
||||
@ -1001,6 +1002,7 @@ static cc_bool GenLevelScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||
if (s->selected) s->selected->base.showCaret = false;
|
||||
s->selected = (struct MenuInputWidget*)&s->inputs[i];
|
||||
s->selected->base.showCaret = true;
|
||||
Window_SetKeyboardText(&s->inputs[i].base.text);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2100,6 +2102,7 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
|
||||
|
||||
MenuOptionsScreen_RedrawInput(s);
|
||||
Window_OpenKeyboard();
|
||||
Window_SetKeyboardText(&value);
|
||||
}
|
||||
|
||||
static void MenuOptionsScreen_OnHacksChanged(void* screen) {
|
||||
|
@ -233,7 +233,7 @@ static const struct ScreenVTABLE HUDScreen_VTABLE = {
|
||||
void HUDScreen_Show(void) {
|
||||
struct HUDScreen* s = &HUDScreen_Instance;
|
||||
s->VTABLE = &HUDScreen_VTABLE;
|
||||
Gui_HUD = (struct Screen*)s;
|
||||
Gui_HUD = s;
|
||||
Gui_Replace((struct Screen*)s, GUI_PRIORITY_STATUS);
|
||||
}
|
||||
|
||||
@ -822,13 +822,14 @@ void ChatScreen_Show(void) {
|
||||
s->lastDownloadStatus = Int32_MinValue;
|
||||
|
||||
s->VTABLE = &ChatScreen_VTABLE;
|
||||
Gui_Chat = (struct Screen*)s;
|
||||
Gui_Chat = s;
|
||||
Gui_Replace((struct Screen*)s, GUI_PRIORITY_HUD);
|
||||
}
|
||||
|
||||
void ChatScreen_OpenInput(const String* text) {
|
||||
struct ChatScreen* s = &ChatScreen_Instance;
|
||||
struct ChatScreen* s = &ChatScreen_Instance;
|
||||
#ifdef CC_BUILD_TOUCH
|
||||
/* TODO: This is the wrong approach. need an event for all text input. */
|
||||
s->suppressNextPress = !Input_TouchMode;
|
||||
#else
|
||||
s->suppressNextPress = true;
|
||||
@ -836,6 +837,7 @@ void ChatScreen_OpenInput(const String* text) {
|
||||
s->grabsInput = true;
|
||||
Camera_CheckFocus();
|
||||
Window_OpenKeyboard();
|
||||
Window_SetKeyboardText(text);
|
||||
|
||||
String_Copy(&s->input.base.text, text);
|
||||
InputWidget_UpdateText(&s->input.base);
|
||||
|
25
src/Window.c
25
src/Window.c
@ -615,6 +615,7 @@ static void Window_InitRawMouse(void) {
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(void) { }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
|
||||
void Window_EnableRawMouse(void) {
|
||||
@ -1518,6 +1519,7 @@ void Window_FreeFramebuffer(Bitmap* bmp) {
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(void) { }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
void Window_EnableRawMouse(void) { Window_DefaultEnableRawMouse(); }
|
||||
void Window_UpdateRawMouse(void) { Window_DefaultUpdateRawMouse(); }
|
||||
@ -1788,6 +1790,7 @@ void Cursor_SetVisible(cc_bool visible) {
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(void) { }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
|
||||
void Window_EnableRawMouse(void) {
|
||||
@ -2711,12 +2714,9 @@ void Window_FreeFramebuffer(Bitmap* bmp) {
|
||||
/* TODO: Do we still need to unlock it though? */
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(void) {
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
void Window_CloseKeyboard(void) {
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
void Window_OpenKeyboard(void) { SDL_StartTextInput(); }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { SDL_StopTextInput(); }
|
||||
|
||||
void Window_EnableRawMouse(void) {
|
||||
Window_RegrabMouse();
|
||||
@ -3224,9 +3224,19 @@ void Window_OpenKeyboard(void) {
|
||||
});
|
||||
}
|
||||
|
||||
void Window_SetKeyboardText(const String* text) {
|
||||
char str[600];
|
||||
if (!Input_TouchMode) return;
|
||||
Platform_ConvertString(str, text);
|
||||
|
||||
EM_ASM_({
|
||||
if (!window.cc_inputElem) return;
|
||||
window.cc_inputElem.value = UTF8ToString($0);
|
||||
}, str);
|
||||
}
|
||||
|
||||
void Window_CloseKeyboard(void) {
|
||||
if (!Input_TouchMode) return;
|
||||
Platform_LogConst("CLOSE SESAME");
|
||||
EM_ASM({
|
||||
if (!window.cc_inputElem) return;
|
||||
document.body.removeChild(window.cc_inputElem);
|
||||
@ -3630,6 +3640,7 @@ void Window_OpenKeyboard(void) {
|
||||
JavaGetCurrentEnv(env);
|
||||
JavaCallVoid(env, "openKeyboard", "()V", NULL);
|
||||
}
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
|
||||
void Window_CloseKeyboard(void) {
|
||||
JNIEnv* env;
|
||||
|
@ -126,6 +126,12 @@ void Window_FreeFramebuffer(Bitmap* bmp);
|
||||
/* Displays on-screen keyboard for platforms that lack physical keyboard input. */
|
||||
/* NOTE: On desktop platforms, this won't do anything. */
|
||||
void Window_OpenKeyboard(void);
|
||||
/* Sets the text used for keyboard input. */
|
||||
/* NOTE: This is only used for mobile on-screen keyboard input with the web client, */
|
||||
/* because it is backed by a HTML input, rather than true keyboard input events. */
|
||||
/* As such, this is necessary to ensure the HTML input is consistent with */
|
||||
/* whatever text input widget is actually being displayed on screen. */
|
||||
void Window_SetKeyboardText(const String* text);
|
||||
/* Hides/Removes the previously displayed on-screen keyboard. */
|
||||
void Window_CloseKeyboard(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user