TextAreaWidget: Fix erase handling with unicode characters

This commit is contained in:
Lynix 2019-12-23 18:43:21 +01:00
parent e6c0f864f3
commit dec857d807
2 changed files with 4 additions and 4 deletions

View File

@ -72,10 +72,10 @@ namespace Ndk
Nz::String newText; Nz::String newText;
if (firstGlyph > blockFirstGlyph) if (firstGlyph > blockFirstGlyph)
{ {
std::size_t characterPosition = blockText.GetCharacterPosition(firstGlyph - blockFirstGlyph - 1); std::size_t characterPosition = blockText.GetCharacterPosition(firstGlyph - blockFirstGlyph);
NazaraAssert(characterPosition != Nz::String::npos, "Invalid character position"); NazaraAssert(characterPosition != Nz::String::npos, "Invalid character position");
newText.Append(blockText.SubString(0, characterPosition)); newText.Append(blockText.SubString(0, characterPosition - 1));
} }
if (lastGlyph < textLength) if (lastGlyph < textLength)

View File

@ -74,10 +74,10 @@ namespace Ndk
Nz::String newText; Nz::String newText;
if (firstGlyph > 0) if (firstGlyph > 0)
{ {
std::size_t characterPosition = m_text.GetCharacterPosition(firstGlyph - 1); std::size_t characterPosition = m_text.GetCharacterPosition(firstGlyph);
NazaraAssert(characterPosition != Nz::String::npos, "Invalid character position"); NazaraAssert(characterPosition != Nz::String::npos, "Invalid character position");
newText.Append(m_text.SubString(0, characterPosition)); newText.Append(m_text.SubString(0, characterPosition - 1));
} }
if (lastGlyph < textLength) if (lastGlyph < textLength)