MCPcopy Create free account
hub / github.com/MyGUI/mygui / setText

Method setText

MyGUIEngine/src/MyGUI_EditBox.cpp:1269–1320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1267 }
1268
1269 void EditBox::setText(const UString& _caption, bool _history)
1270 {
1271 // сбрасываем выделение
1272 resetSelect();
1273
1274 // история изменений
1275 VectorChangeInfo* history = nullptr;
1276 if (_history)
1277 history = new VectorChangeInfo();
1278
1279 // итератор нашей строки
1280 TextIterator iterator(getRealString(), history);
1281
1282 // вставляем текст
1283 iterator.setText(_caption, mModeMultiline || mModeWordWrap);
1284
1285 if (mOverflowToTheLeft)
1286 {
1287 iterator.cutMaxLengthFromBeginning(mMaxTextLength);
1288 }
1289 else
1290 {
1291 // обрезаем по максимальной длинне
1292 iterator.cutMaxLength(mMaxTextLength);
1293 }
1294
1295 // запоминаем размер строки
1296 size_t old = mTextLength;
1297 // новая позиция и положение на конец вставки
1298 mCursorPosition = mTextLength = iterator.getSize();
1299
1300 // сохраняем позицию для восстановления курсора
1301 commandPosition(0, mTextLength, old, history);
1302
1303 // запоминаем в историю
1304 if (_history)
1305 {
1306 saveInHistory(history);
1307 delete history;
1308 }
1309 // сбрасываем историю
1310 else
1311 commandResetHistory();
1312
1313 // и возвращаем строку на место
1314 setRealString(iterator.getText());
1315
1316 // обновляем по позиции
1317 if (mClientText != nullptr)
1318 mClientText->setCursorPosition(mCursorPosition);
1319 updateSelectText();
1320 }
1321
1322 void EditBox::insertText(const UString& _text, size_t _start, bool _history)
1323 {

Callers

nothing calls this directly

Calls 5

cutMaxLengthMethod · 0.80
setCursorPositionMethod · 0.80
getSizeMethod · 0.45
getTextMethod · 0.45

Tested by

no test coverage detected