Browse Source

Update raygui.h (#279)

fix for #278
PROP 65 2 years ago
parent
commit
6fc9337cd8
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/raygui.h

+ 6 - 2
src/raygui.h

@@ -2229,8 +2229,12 @@ bool GuiTextBox(Rectangle bounds, char *text, int bufferSize, bool editMode)
                     // Move backward text from cursor position
                     // Move backward text from cursor position
                     for (int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize];
                     for (int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize];
 
 
-                    textBoxCursorIndex -= codepointSize;
-                    textLength -= codepointSize;
+                    // Prevent textBoxCursorIndex from decrementing past 0
+                    if(textBoxCursorIndex > 0)
+                    {
+                        textBoxCursorIndex -= codepointSize;
+                        textLength -= codepointSize;
+                    }
 
 
                     // Make sure text last character is EOL
                     // Make sure text last character is EOL
                     text[textLength] = '\0';
                     text[textLength] = '\0';