mirror of
https://github.com/raysan5/raygui.git
synced 2026-01-30 18:59:18 -05:00
Fix GuiTextBox handling of codepoints when deleting text and clicking with mouse (#462)
This commit is contained in:
@ -2642,7 +2642,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
// Move backward text from cursor position
|
// Move backward text from cursor position
|
||||||
for (int i = textBoxCursorIndex; i < textLength; i++) text[i] = text[i + nextCodepointSize];
|
for (int i = textBoxCursorIndex; i < textLength; i++) text[i] = text[i + nextCodepointSize];
|
||||||
|
|
||||||
textLength -= codepointSize;
|
textLength -= nextCodepointSize;
|
||||||
if (textBoxCursorIndex > textLength) textBoxCursorIndex = textLength;
|
if (textBoxCursorIndex > textLength) textBoxCursorIndex = textLength;
|
||||||
|
|
||||||
// Make sure text last character is EOL
|
// Make sure text last character is EOL
|
||||||
@ -2703,8 +2703,8 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, 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;
|
textBoxCursorIndex -= prevCodepointSize;
|
||||||
textLength -= codepointSize;
|
textLength -= prevCodepointSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure text last character is EOL
|
// Make sure text last character is EOL
|
||||||
@ -2747,7 +2747,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
float widthToMouseX = 0;
|
float widthToMouseX = 0;
|
||||||
int mouseCursorIndex = 0;
|
int mouseCursorIndex = 0;
|
||||||
|
|
||||||
for (int i = textIndexOffset; i < textLength; i++)
|
for (int i = textIndexOffset; i < textLength; i += codepointSize)
|
||||||
{
|
{
|
||||||
codepoint = GetCodepointNext(&text[i], &codepointSize);
|
codepoint = GetCodepointNext(&text[i], &codepointSize);
|
||||||
codepointIndex = GetGlyphIndex(guiFont, codepoint);
|
codepointIndex = GetGlyphIndex(guiFont, codepoint);
|
||||||
|
|||||||
Reference in New Issue
Block a user