MCPcopy Create free account
hub / github.com/VCVRack/Rack / insertText

Method insertText

src/ui/TextField.cpp:348–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348void TextField::insertText(std::string text) {
349 // Rack uses UNIX newlines so remove all CR characters
350 text.erase(std::remove(text.begin(), text.end(), '\r'), text.end());
351
352 bool changed = false;
353 if (cursor != selection) {
354 // Delete selected text
355 int begin = std::min(cursor, selection);
356 int len = std::abs(selection - cursor);
357 this->text.erase(begin, len);
358 cursor = selection = begin;
359 changed = true;
360 }
361 if (!text.empty()) {
362 this->text.insert(cursor, text);
363 cursor += text.size();
364 selection = cursor;
365 changed = true;
366 }
367 if (changed) {
368 ChangeEvent eChange;
369 onChange(eChange);
370 }
371}
372
373void TextField::copyClipboard() {
374 if (cursor == selection)

Callers

nothing calls this directly

Calls 5

removeFunction · 0.85
minFunction · 0.85
absFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected