| 591 | } |
| 592 | |
| 593 | void TextFieldTTF::makeStringSupportCursor(std::string& displayText) |
| 594 | { |
| 595 | if (_cursorEnabled && _isAttachWithIME) |
| 596 | { |
| 597 | if (displayText.empty()) |
| 598 | { |
| 599 | // \b - Next char not change x position |
| 600 | if (_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::BMFONT) |
| 601 | displayText.push_back(StringUtils::AsciiCharacters::NextCharNoChangeX); |
| 602 | displayText.push_back(_cursorChar); |
| 603 | } |
| 604 | else |
| 605 | { |
| 606 | auto numChars = StringUtils::countUTF8Chars(displayText); |
| 607 | if (_cursorPosition > numChars) |
| 608 | _cursorPosition = numChars; |
| 609 | |
| 610 | std::string cursorChar; |
| 611 | // \b - Next char not change x position |
| 612 | if (_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::BMFONT) |
| 613 | cursorChar.push_back(StringUtils::AsciiCharacters::NextCharNoChangeX); |
| 614 | cursorChar.push_back(_cursorChar); |
| 615 | |
| 616 | auto offset = StringUtils::getUTF8ByteOffset(displayText, _cursorPosition); |
| 617 | if (offset != std::string::npos) |
| 618 | displayText.insert(offset, cursorChar); |
| 619 | else |
| 620 | displayText += cursorChar; |
| 621 | } |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | void TextFieldTTF::updateCursorDisplayText() |
| 626 | { |
nothing calls this directly
no test coverage detected