diff options
author | Ian C <ianc@noddybox.co.uk> | 2023-04-23 10:09:35 +0800 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2023-04-23 10:09:35 +0800 |
commit | d68d6a14ba9c37eef243d6b739d590ec0f05c6c4 (patch) | |
tree | 4b6b5c90f00b7b5132ed67d5007567273541f9a1 /source | |
parent | fc70a9899db0028122a2c308975b8c11eee878de (diff) |
Added backspace key to GUI_Input()
Diffstat (limited to 'source')
-rw-r--r-- | source/gui.c | 67 |
1 files 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; } } } |