From d68d6a14ba9c37eef243d6b739d590ec0f05c6c4 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 23 Apr 2023 10:09:35 +0800 Subject: Added backspace key to GUI_Input() --- source/gui.c | 67 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/source/gui.c b/source/gui.c index 62edefe..bf1feb5 100644 --- a/source/gui.c +++ b/source/gui.c @@ -936,7 +936,7 @@ int GUI_Input(const char *prompt, char text[], int maxlen) {SK_7, '7', 0}, {SK_8, '8', 0}, {SK_9, '9', 0}, - {SK_0, '0', 0}, + {SK_0, '0', 8}, {SK_A, 'A', 0}, {SK_B, 'B', '*'}, {SK_C, 'C', '?'}, @@ -1033,35 +1033,42 @@ int GUI_Input(const char *prompt, char text[], int maxlen) break; default: - if (l < maxlen) - { - f = 0; - ascii = 0; - - while(!ascii && keymap[f].ascii) - { - if (ev.key == keymap[f].key) - { - if (shifted) - { - ascii = keymap[f].shift; - } - else - { - ascii = keymap[f].ascii; - } - } - - f++; - } - - if (ascii) - { - text[l++] = ascii; - text[l] = 0; - } - } - break; + f = 0; + ascii = 0; + + while(!ascii && keymap[f].ascii) + { + if (ev.key == keymap[f].key) + { + if (shifted) + { + ascii = keymap[f].shift; + } + else + { + ascii = keymap[f].ascii; + } + } + + f++; + } + + if (ascii == 8) + { + if (l) + { + text[--l] = 0; + } + } + else if (ascii) + { + if (l < maxlen) + { + text[l++] = ascii; + text[l] = 0; + } + } + break; } } } -- cgit v1.2.3