diff options
| author | raysan5 <raysan5@gmail.com> | 2019-11-24 13:39:45 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2019-11-24 13:39:45 +0100 |
| commit | 1d3f230c92f2f8d611fb4372bcc7ea1a454ca4ba (patch) | |
| tree | f4e392faf84fe5d02fa78a2cb025737cc0cdc610 /examples | |
| parent | ae301a1d233d9fcde676e0572cc2eab9206a8ad2 (diff) | |
| download | raylib-1d3f230c92f2f8d611fb4372bcc7ea1a454ca4ba.tar.gz raylib-1d3f230c92f2f8d611fb4372bcc7ea1a454ca4ba.zip | |
Review key input queue PR #1012
Keeping original API
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/text/text_input_box.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/examples/text/text_input_box.c b/examples/text/text_input_box.c index ea3d2992..981ae80d 100644 --- a/examples/text/text_input_box.c +++ b/examples/text/text_input_box.c @@ -30,7 +30,7 @@ int main(void) int framesCounter = 0; - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(10); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -43,13 +43,20 @@ int main(void) if (mouseOnText) { + // Get pressed key (character) on the queue int key = GetKeyPressed(); - // NOTE: Only allow keys in range [32..125] - if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS)) + // Check if more characters have been pressed on the same frame + while (key > 0) { - name[letterCount] = (char)key; - letterCount++; + // NOTE: Only allow keys in range [32..125] + if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS)) + { + name[letterCount] = (char)key; + letterCount++; + } + + key = GetKeyPressed(); // Check next character in the queue } if (IsKeyPressed(KEY_BACKSPACE)) |
