mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Fix backspace not working properly on some mobile devices
This commit is contained in:
parent
93cdbdd2c5
commit
746191384d
15
src/Menus.c
15
src/Menus.c
@ -831,7 +831,7 @@ static int EditHotkeyScreen_KeyPress(void* screen, char keyChar) {
|
|||||||
static int EditHotkeyScreen_TextChanged(void* screen, const String* str) {
|
static int EditHotkeyScreen_TextChanged(void* screen, const String* str) {
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
||||||
InputWidget_SetAndSyncText(&s->input.base, str);
|
InputWidget_SetText(&s->input.base, str);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1023,7 +1023,7 @@ static int GenLevelScreen_KeyPress(void* screen, char keyChar) {
|
|||||||
static int GenLevelScreen_TextChanged(void* screen, const String* str) {
|
static int GenLevelScreen_TextChanged(void* screen, const String* str) {
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
||||||
if (s->selected) InputWidget_SetAndSyncText(&s->selected->base, str);
|
if (s->selected) InputWidget_SetText(&s->selected->base, str);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1377,7 +1377,7 @@ static int SaveLevelScreen_TextChanged(void* screen, const String* str) {
|
|||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
||||||
SaveLevelScreen_RemoveOverwrites(s);
|
SaveLevelScreen_RemoveOverwrites(s);
|
||||||
InputWidget_SetAndSyncText(&s->input.base, str);
|
InputWidget_SetText(&s->input.base, str);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2055,7 +2055,7 @@ static int MenuOptionsScreen_KeyPress(void* screen, char keyChar) {
|
|||||||
static int MenuOptionsScreen_TextChanged(void* screen, const String* str) {
|
static int MenuOptionsScreen_TextChanged(void* screen, const String* str) {
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
||||||
if (s->activeI >= 0) InputWidget_SetAndSyncText(&s->input.base, str);
|
if (s->activeI >= 0) InputWidget_SetText(&s->input.base, str);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2112,14 +2112,11 @@ static void MenuOptionsScreen_OK(void* screen, void* widget) {
|
|||||||
static void MenuOptionsScreen_Default(void* screen, void* widget) {
|
static void MenuOptionsScreen_Default(void* screen, void* widget) {
|
||||||
String value; char valueBuffer[STRING_SIZE];
|
String value; char valueBuffer[STRING_SIZE];
|
||||||
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
||||||
struct MenuInputDesc* desc;
|
struct MenuInputDesc* desc = &s->descs[s->activeI];
|
||||||
|
|
||||||
desc = &s->descs[s->activeI];
|
|
||||||
String_InitArray(value, valueBuffer);
|
String_InitArray(value, valueBuffer);
|
||||||
desc->VTABLE->GetDefault(desc, &value);
|
desc->VTABLE->GetDefault(desc, &value);
|
||||||
|
InputWidget_SetText(&s->input.base, &value);
|
||||||
InputWidget_Clear(&s->input.base);
|
|
||||||
InputWidget_AppendString(&s->input.base, &value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MenuOptionsScreen_Bool(void* screen, void* widget) {
|
static void MenuOptionsScreen_Bool(void* screen, void* widget) {
|
||||||
|
@ -727,7 +727,7 @@ static int ChatScreen_TextChanged(void* screen, const String* str) {
|
|||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
if (!s->grabsInput) return false;
|
if (!s->grabsInput) return false;
|
||||||
|
|
||||||
InputWidget_SetAndSyncText(&s->input.base, str);
|
InputWidget_SetText(&s->input.base, str);
|
||||||
ChatScreen_UpdateChatYOffsets(s);
|
ChatScreen_UpdateChatYOffsets(s);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
@ -965,7 +965,7 @@ void ChatScreen_OpenInput(const String* text) {
|
|||||||
|
|
||||||
void ChatScreen_AppendInput(const String* text) {
|
void ChatScreen_AppendInput(const String* text) {
|
||||||
struct ChatScreen* s = &ChatScreen_Instance;
|
struct ChatScreen* s = &ChatScreen_Instance;
|
||||||
InputWidget_AppendString(&s->input.base, text);
|
InputWidget_AppendText(&s->input.base, text);
|
||||||
ChatScreen_UpdateChatYOffsets(s);
|
ChatScreen_UpdateChatYOffsets(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1060,7 +1060,7 @@ static cc_bool InputWidget_TryAppendChar(struct InputWidget* w, char c) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputWidget_AppendString(struct InputWidget* w, const String* text) {
|
void InputWidget_AppendText(struct InputWidget* w, const String* text) {
|
||||||
int i, appended = 0;
|
int i, appended = 0;
|
||||||
for (i = 0; i < text->length; i++) {
|
for (i = 0; i < text->length; i++) {
|
||||||
if (InputWidget_TryAppendChar(w, text->buffer[i])) appended++;
|
if (InputWidget_TryAppendChar(w, text->buffer[i])) appended++;
|
||||||
@ -1174,7 +1174,7 @@ static void InputWidget_EndKey(struct InputWidget* w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void InputWidget_CopyFromClipboard(String* text, void* w) {
|
static void InputWidget_CopyFromClipboard(String* text, void* w) {
|
||||||
InputWidget_AppendString((struct InputWidget*)w, text);
|
InputWidget_AppendText((struct InputWidget*)w, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool InputWidget_OtherKey(struct InputWidget* w, int key) {
|
static cc_bool InputWidget_OtherKey(struct InputWidget* w, int key) {
|
||||||
@ -1204,12 +1204,14 @@ void InputWidget_UpdateText(struct InputWidget* w) {
|
|||||||
InputWidget_CalculateLineSizes(w);
|
InputWidget_CalculateLineSizes(w);
|
||||||
w->RemakeTexture(w);
|
w->RemakeTexture(w);
|
||||||
InputWidget_UpdateCaret(w);
|
InputWidget_UpdateCaret(w);
|
||||||
|
Window_SetKeyboardText(&w->text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputWidget_SetAndSyncText(struct InputWidget* w, const String* str) {
|
void InputWidget_SetText(struct InputWidget* w, const String* str) {
|
||||||
InputWidget_Clear(w);
|
InputWidget_Clear(w);
|
||||||
InputWidget_AppendString(w, str);
|
InputWidget_AppendText(w, str);
|
||||||
Window_SetKeyboardText(&w->text);
|
/* If text is empty, InputWidget_UpdateText won't have been called */
|
||||||
|
if (!w->text.length) Window_SetKeyboardText(&w->text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InputWidget_Free(void* widget) {
|
static void InputWidget_Free(void* widget) {
|
||||||
@ -1723,7 +1725,7 @@ static void ChatInputWidget_TabKey(struct InputWidget* w) {
|
|||||||
|
|
||||||
if (w->caretPos != -1) w->caretPos -= len;
|
if (w->caretPos != -1) w->caretPos -= len;
|
||||||
name = TabList_UNSAFE_GetPlayer(matches[0]);
|
name = TabList_UNSAFE_GetPlayer(matches[0]);
|
||||||
InputWidget_AppendString(w, &name);
|
InputWidget_AppendText(w, &name);
|
||||||
} else if (numMatches > 1) {
|
} else if (numMatches > 1) {
|
||||||
String_InitArray(str, strBuffer);
|
String_InitArray(str, strBuffer);
|
||||||
String_Format1(&str, "&e%i matching names: ", &numMatches);
|
String_Format1(&str, "&e%i matching names: ", &numMatches);
|
||||||
@ -2573,7 +2575,7 @@ static void SpecialInputWidget_IntersectsBody(struct SpecialInputWidget* w, int
|
|||||||
|
|
||||||
/* TODO: Not be so hacky */
|
/* TODO: Not be so hacky */
|
||||||
if (w->selectedIndex == 0) str.length = 2;
|
if (w->selectedIndex == 0) str.length = 2;
|
||||||
InputWidget_AppendString(w->target, &str);
|
InputWidget_AppendText(w->target, &str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SpecialInputTab_Init(struct SpecialInputTab* tab, STRING_REF String* title, int itemsPerRow, int charsPerItem, STRING_REF String* contents) {
|
static void SpecialInputTab_Init(struct SpecialInputTab* tab, STRING_REF String* title, int itemsPerRow, int charsPerItem, STRING_REF String* contents) {
|
||||||
|
@ -130,16 +130,19 @@ struct InputWidget {
|
|||||||
/* Removes all characters and then deletes the input texture. */
|
/* Removes all characters and then deletes the input texture. */
|
||||||
CC_NOINLINE void InputWidget_Clear(struct InputWidget* w);
|
CC_NOINLINE void InputWidget_Clear(struct InputWidget* w);
|
||||||
/* Tries appending all characters from the given string, then update the input texture. */
|
/* Tries appending all characters from the given string, then update the input texture. */
|
||||||
CC_NOINLINE void InputWidget_AppendString(struct InputWidget* w, const String* text);
|
CC_NOINLINE void InputWidget_AppendText(struct InputWidget* w, const String* text);
|
||||||
/* Tries appending the given character, then updates the input texture. */
|
/* Tries appending the given character, then updates the input texture. */
|
||||||
CC_NOINLINE void InputWidget_Append(struct InputWidget* w, char c);
|
CC_NOINLINE void InputWidget_Append(struct InputWidget* w, char c);
|
||||||
/* Redraws text and recalculates associated state. */
|
/* Redraws text and recalculates associated state. */
|
||||||
|
/* Also calls Window_SetKeyboardText with the text in the input widget. */
|
||||||
|
/* This way native text input state stays synchronised with the input widget. */
|
||||||
|
/* (e.g. may only accept numerical input, so 'c' gets stripped from str) */
|
||||||
CC_NOINLINE void InputWidget_UpdateText(struct InputWidget* w);
|
CC_NOINLINE void InputWidget_UpdateText(struct InputWidget* w);
|
||||||
/* Shorthand for InputWidget_Clear followed by InputWidget_AppendString, */
|
/* Shorthand for InputWidget_Clear followed by InputWidget_AppendText, */
|
||||||
/* then calls Window_SetKeyboardText with the text in the input widget. */
|
/* then calls Window_SetKeyboardText with the text in the input widget. */
|
||||||
/* This way native text input state stays synchronised with the input widget. */
|
/* This way native text input state stays synchronised with the input widget. */
|
||||||
/* (e.g. may only accept numerical input, so 'c' gets stripped from str) */
|
/* (e.g. may only accept numerical input, so 'c' gets stripped from str) */
|
||||||
CC_NOINLINE void InputWidget_SetAndSyncText(struct InputWidget* w, const String* str);
|
CC_NOINLINE void InputWidget_SetText(struct InputWidget* w, const String* str);
|
||||||
|
|
||||||
|
|
||||||
struct MenuInputDesc;
|
struct MenuInputDesc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user