mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Backport adding text argument to Window_OpenKeyboard from AndroidInputTouch branch
This commit is contained in:
parent
9225aecfad
commit
6607e15100
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Android build results
|
||||
android/.idea/
|
||||
android/.gradle/
|
||||
android/build/
|
||||
android/app/build/
|
||||
|
@ -191,7 +191,7 @@ void Gfx_BeginFrame(void);
|
||||
void Gfx_EndFrame(void);
|
||||
/* Sets whether to synchronise with monitor refresh to avoid tearing, and maximum frame rate. */
|
||||
/* NOTE: VSync setting may be unsupported or just ignored. */
|
||||
void Gfx_SetFpsLimit(cc_bool value, float minFrameMillis);
|
||||
void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMillis);
|
||||
/* Updates state when the window's dimensions have changed. */
|
||||
/* NOTE: This may require recreating the context depending on the backend. */
|
||||
void Gfx_OnWindowResize(void);
|
||||
|
@ -67,8 +67,7 @@ struct ScreenVTABLE {
|
||||
int (*HandlesInputUp)(void* elem, int key);
|
||||
/* Returns non-zero if a key character press is handled. */
|
||||
int (*HandlesKeyPress)(void* elem, char keyChar);
|
||||
/* Returns non-zero if a key character press is handled. */
|
||||
/* Currently only raised by on-screen keyboard in web client. */
|
||||
/* Returns non-zero if on-screen keyboard text changed is handled. */
|
||||
int (*HandlesTextChanged)(void* elem, const String* str);
|
||||
/* Returns non-zero if a pointer press is handled. */
|
||||
int (*HandlesPointerDown)(void* elem, int id, int x, int y);
|
||||
|
@ -417,12 +417,13 @@ static void LInput_MoveCaretToCursor(struct LInput* w) {
|
||||
}
|
||||
|
||||
static void LInput_Select(void* widget, cc_bool wasSelected) {
|
||||
struct LInput* w = (struct LInput*)widget;
|
||||
caretStart = DateTime_CurrentUTC_MS();
|
||||
LInput_MoveCaretToCursor((struct LInput*)widget);
|
||||
LInput_MoveCaretToCursor(w);
|
||||
/* TODO: Only draw outer border */
|
||||
if (wasSelected) return;
|
||||
LWidget_Draw(widget);
|
||||
Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
|
||||
Window_OpenKeyboard(&w->text, KEYBOARD_TYPE_TEXT);
|
||||
}
|
||||
|
||||
static void LInput_Unselect(void* widget) {
|
||||
|
10
src/Menus.c
10
src/Menus.c
@ -944,8 +944,7 @@ static void EditHotkeyScreen_Init(void* screen) {
|
||||
|
||||
MenuInputWidget_Create(&s->input, 500, &text, &desc);
|
||||
Menu_InitBack(&s->cancel, Menu_SwitchHotkeys);
|
||||
Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
|
||||
Window_SetKeyboardText(&text);
|
||||
Window_OpenKeyboard(&text, KEYBOARD_TYPE_TEXT);
|
||||
}
|
||||
|
||||
static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
|
||||
@ -1149,7 +1148,7 @@ static void GenLevelScreen_Init(void* screen) {
|
||||
ButtonWidget_Init(&s->flatgrass, 200, GenLevelScreen_Flatgrass);
|
||||
ButtonWidget_Init(&s->vanilla, 200, GenLevelScreen_Notchy);
|
||||
Menu_InitBack(&s->cancel, Menu_SwitchPause);
|
||||
Window_OpenKeyboard(KEYBOARD_TYPE_NUMBER);
|
||||
Window_OpenKeyboard(&String_Empty, KEYBOARD_TYPE_NUMBER);
|
||||
}
|
||||
|
||||
static const struct ScreenVTABLE GenLevelScreen_VTABLE = {
|
||||
@ -1505,7 +1504,7 @@ static void SaveLevelScreen_Init(void* screen) {
|
||||
Menu_InitBack(&s->cancel, Menu_SwitchPause);
|
||||
MenuInputWidget_Create(&s->input, 500, &String_Empty, &desc);
|
||||
TextWidget_Init(&s->desc);
|
||||
Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
|
||||
Window_OpenKeyboard(&String_Empty, KEYBOARD_TYPE_TEXT);
|
||||
}
|
||||
|
||||
static const struct ScreenVTABLE SaveLevelScreen_VTABLE = {
|
||||
@ -2252,8 +2251,7 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
|
||||
s->numWidgets = MENUOPTS_MAX_OPTS + 1 + 3;
|
||||
MenuOptionsScreen_Layout(screen);
|
||||
MenuOptionsScreen_RedrawInput(s);
|
||||
Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
|
||||
Window_SetKeyboardText(&value);
|
||||
Window_OpenKeyboard(&value, KEYBOARD_TYPE_TEXT);
|
||||
}
|
||||
|
||||
static void MenuOptionsScreen_OnHacksChanged(void* screen) {
|
||||
|
@ -1278,8 +1278,7 @@ void ChatScreen_OpenInput(const String* text) {
|
||||
s->suppressNextPress = true;
|
||||
s->grabsInput = true;
|
||||
Camera_CheckFocus();
|
||||
Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
|
||||
Window_SetKeyboardText(text);
|
||||
Window_OpenKeyboard(text, KEYBOARD_TYPE_TEXT);
|
||||
|
||||
String_Copy(&s->input.base.text, text);
|
||||
InputWidget_UpdateText(&s->input.base);
|
||||
|
25
src/Window.c
25
src/Window.c
@ -401,9 +401,9 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
||||
/* TODO: Do we still need to unlock it though? */
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(int type) { SDL_StartTextInput(); }
|
||||
void Window_OpenKeyboard(const String* text, int type) { SDL_StartTextInput(); }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { SDL_StopTextInput(); }
|
||||
void Window_CloseKeyboard(void) { SDL_StopTextInput(); }
|
||||
|
||||
void Window_EnableRawMouse(void) {
|
||||
RegrabMouse();
|
||||
@ -934,9 +934,9 @@ static void InitRawMouse(void) {
|
||||
rawMouseSupported = false;
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(int type) { }
|
||||
void Window_OpenKeyboard(const String* text, int type) { }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
|
||||
void Window_EnableRawMouse(void) {
|
||||
DefaultEnableRawMouse();
|
||||
@ -1818,9 +1818,9 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
||||
Mem_Free(bmp->scan0);
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(int type) { }
|
||||
void Window_OpenKeyboard(const String* text, int type) { }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
|
||||
static cc_bool rawMouseInited, rawMouseSupported;
|
||||
static int xiOpcode;
|
||||
@ -2034,9 +2034,9 @@ static void Cursor_DoSetVisible(cc_bool visible) {
|
||||
}
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(int type) { }
|
||||
void Window_OpenKeyboard(const String* text, int type) { }
|
||||
void Window_SetKeyboardText(const String* text) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
void Window_CloseKeyboard(void) { }
|
||||
|
||||
void Window_EnableRawMouse(void) {
|
||||
DefaultEnableRawMouse();
|
||||
@ -3500,9 +3500,11 @@ EMSCRIPTEN_KEEPALIVE void Window_OnTextChanged(const char* src) {
|
||||
Event_RaiseString(&InputEvents.TextChanged, &str);
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(int type) {
|
||||
void Window_OpenKeyboard(const String* text, int type) {
|
||||
char str[NATIVE_STR_LEN];
|
||||
if (!Input_TouchMode) return;
|
||||
keyboardOpen = true;
|
||||
Platform_ConvertString(str, text);
|
||||
Platform_LogConst("OPEN SESAME");
|
||||
|
||||
EM_ASM_({
|
||||
@ -3510,6 +3512,7 @@ void Window_OpenKeyboard(int type) {
|
||||
if (!elem) {
|
||||
elem = document.createElement('textarea');
|
||||
elem.setAttribute('style', 'position:absolute; left:0; top:0; width:100%; height:100%; opacity:0.3; resize:none; pointer-events:none;');
|
||||
elem.value = UTF8ToString($0);
|
||||
|
||||
elem.addEventListener("input",
|
||||
function(ev) {
|
||||
@ -3521,7 +3524,7 @@ void Window_OpenKeyboard(int type) {
|
||||
}
|
||||
elem.focus();
|
||||
elem.click();
|
||||
}, type);
|
||||
}, str, type);
|
||||
}
|
||||
|
||||
void Window_SetKeyboardText(const String* text) {
|
||||
@ -3930,7 +3933,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
||||
Mem_Free(bmp->scan0);
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(int type) {
|
||||
void Window_OpenKeyboard(const String* text, int type) {
|
||||
JNIEnv* env;
|
||||
JavaGetCurrentEnv(env);
|
||||
JavaCallVoid(env, "openKeyboard", "()V", NULL);
|
||||
|
@ -34,7 +34,7 @@ struct Bitmap;
|
||||
struct DynamicLibSym;
|
||||
/* The states the window can be in. */
|
||||
enum WindowState { WINDOW_STATE_NORMAL, WINDOW_STATE_MINIMISED, WINDOW_STATE_FULLSCREEN };
|
||||
enum KeyboardType { KEYBOARD_TYPE_TEXT, KEYBOARD_TYPE_PASSWORD, KEYBOARD_TYPE_NUMBER };
|
||||
enum KeyboardType { KEYBOARD_TYPE_TEXT, KEYBOARD_TYPE_NUMBER, KEYBOARD_TYPE_PASSWORD };
|
||||
/* Can't name these structs Window/Display, because it conflicts with X11's Window/Display typedef */
|
||||
|
||||
/* Data for the display monitor. */
|
||||
@ -130,7 +130,7 @@ void Window_FreeFramebuffer(struct 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(int type);
|
||||
void Window_OpenKeyboard(const String* text, int type);
|
||||
/* 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. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user