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

Method insertText

core/ui/UITextField.cpp:117–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117void UICCTextField::insertText(const char* text, size_t len)
118{
119 std::string input_text = text;
120
121 if (strcmp(text, "\n") != 0)
122 {
123 if (_maxLengthEnabled)
124 {
125 int32_t text_count = StringUtils::countUTF8Chars(getString());
126 if (text_count >= _maxLength)
127 {
128 // password
129 if (this->isSecureTextEntry())
130 {
131 setPasswordText(getString());
132 }
133 return;
134 }
135
136 int32_t input_count = StringUtils::countUTF8Chars(text);
137 int32_t total = text_count + input_count;
138
139 if (total > _maxLength)
140 {
141 int32_t length = _maxLength - text_count;
142
143 input_text = Helper::getSubStringOfUTF8String(input_text, 0, length);
144 len = input_text.length();
145 }
146 }
147 }
148 TextFieldTTF::insertText(input_text.c_str(), len);
149}
150
151void UICCTextField::openIME()
152{

Callers 2

dispatchInsertTextMethod · 0.45
setStringMethod · 0.45

Calls 7

countUTF8CharsFunction · 0.85
getStringFunction · 0.85
getSubStringOfUTF8StringFunction · 0.85
insertTextFunction · 0.85
isSecureTextEntryMethod · 0.80
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected