diff options
| author | raysan5 <raysan5@gmail.com> | 2016-03-06 19:30:16 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-03-06 19:30:16 +0100 |
| commit | 6ee5718b2e65c69fca695fdf999fa1838c63aa0b (patch) | |
| tree | cb138571d91cba3af6b6ef94b72608ac648420bb /src/raygui.c | |
| parent | d0e7195a16c50b23fd82e7ca7869cc07773ddba2 (diff) | |
| download | raylib-6ee5718b2e65c69fca695fdf999fa1838c63aa0b.tar.gz raylib-6ee5718b2e65c69fca695fdf999fa1838c63aa0b.zip | |
Improved function GetKeyPressed()
To support multiple keys (including function keys)
Diffstat (limited to 'src/raygui.c')
| -rw-r--r-- | src/raygui.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/raygui.c b/src/raygui.c index 3d7a67ec..e66c33b5 100644 --- a/src/raygui.c +++ b/src/raygui.c @@ -789,11 +789,11 @@ int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue) // NOTE: Requires static variables: framesCounter - ERROR! char *GuiTextBox(Rectangle bounds, char *text) { - #define MAX_CHARS_LENGTH 20 - #define KEY_BACKSPACE_TEXT 3 + #define MAX_CHARS_LENGTH 20 + #define KEY_BACKSPACE_TEXT 259 // GLFW BACKSPACE: 3 + 256 int initPos = bounds.x + 4; - char letter = -1; + int letter = -1; static int framesCounter = 0; Vector2 mousePoint = GetMousePosition(); @@ -822,12 +822,15 @@ char *GuiTextBox(Rectangle bounds, char *text) } else { - for (int i = 0; i < MAX_CHARS_LENGTH; i++) + if ((letter >= 32) && (letter < 127)) { - if (text[i] == '\0') + for (int i = 0; i < MAX_CHARS_LENGTH; i++) { - text[i] = letter; - break; + if (text[i] == '\0') + { + text[i] = (char)letter; + break; + } } } } |
