MCPcopy Create free account
hub / github.com/axmolengine/axmol / setString

Method setString

core/ui/UITextFieldEx.cpp:780–827  ·  view source on GitHub ↗

input text property

Source from the content-addressed store, hash-verified

778
779// input text property
780void TextFieldEx::setString(std::string_view text)
781{
782 static char bulletString[] = {(char)0xe2, (char)0x80, (char)0xa2, (char)0x00};
783
784 _inputText = text;
785
786 std::string secureText;
787
788 std::string* displayText = &_inputText;
789
790 if (!_inputText.empty())
791 {
792 if (_secureTextEntry)
793 {
794 size_t length = _inputText.length();
795 displayText = &secureText;
796
797 while (length > 0)
798 {
799 displayText->append(bulletString);
800 --length;
801 }
802 }
803 }
804
805 // if there is no input text, display placeholder instead
806 if (_inputText.empty())
807 {
808 _renderLabel->setTextColor(_colorSpaceHolder);
809 _renderLabel->setString(_placeHolder);
810 }
811 else
812 {
813 _renderLabel->setTextColor(_colorText);
814 _renderLabel->setString(*displayText);
815 }
816
817 bool bInsertAtEnd = (_insertPosUtf8 == _charCount);
818
819 _charCount = StringUtils::countUTF8Chars(_inputText);
820
821 if (bInsertAtEnd)
822 {
823 _insertPosUtf8 = static_cast<int>(_charCount);
824 _insertPos = static_cast<int>(_inputText.length());
825 _cursorPos = static_cast<int>(displayText->length());
826 }
827}
828
829void TextFieldEx::updateContentSize(void)
830{

Callers 5

insertTextMethod · 0.95
deleteBackwardMethod · 0.95
handleDeleteKeyEventMethod · 0.95
setPasswordEnabledMethod · 0.95
setPlaceholderTextMethod · 0.45

Calls 5

countUTF8CharsFunction · 0.85
emptyMethod · 0.45
lengthMethod · 0.45
appendMethod · 0.45
setTextColorMethod · 0.45

Tested by

no test coverage detected