| 361 | } |
| 362 | |
| 363 | void TextField::setString(std::string_view text) |
| 364 | { |
| 365 | std::string strText(text); |
| 366 | |
| 367 | if (isMaxLengthEnabled()) |
| 368 | { |
| 369 | int max = _textFieldRenderer->getMaxLength(); |
| 370 | int32_t text_count = StringUtils::countUTF8Chars(text); |
| 371 | if (text_count > max) |
| 372 | { |
| 373 | strText = Helper::getSubStringOfUTF8String(strText, 0, max); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | if (isPasswordEnabled()) |
| 378 | { |
| 379 | _textFieldRenderer->setPasswordText(strText); |
| 380 | _textFieldRenderer->setString(""); |
| 381 | _textFieldRenderer->insertText(strText.c_str(), strText.size()); |
| 382 | } |
| 383 | else |
| 384 | { |
| 385 | _textFieldRenderer->setString(strText); |
| 386 | } |
| 387 | _textFieldRendererAdaptDirty = true; |
| 388 | updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); |
| 389 | } |
| 390 | |
| 391 | void TextField::setPlaceHolder(std::string_view value) |
| 392 | { |
nothing calls this directly
no test coverage detected