40 GUIStyledTextNodeController::GUIStyledTextNodeController(
GUINode* node)
76 while (inputControllerNodeCandidate !=
nullptr) {
78 input = required_dynamic_cast<GUIStyledTextNode*>(this->
node)->isEditable();
82 inputControllerNodeCandidate = inputControllerNodeCandidate->getParentControllerNode();
93 if (
input ==
false)
return;
96 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
98 const auto& styledTextNodeBorder = styledTextNode->getBorder();
99 const auto& styledTextNodePadding = styledTextNode->getPadding();
100 auto styledTextNodeAutoWidth = styledTextNode->getContentWidth();
101 auto parentNode = styledTextNode->getParentNode();
102 auto parentNodeWidth = parentNode->getComputedConstraints().width;
103 const auto& parentNodeBorder = parentNode->getBorder();
104 const auto& parentNodePadding = parentNode->getPadding();
105 if (parentNodeWidth > styledTextNodeAutoWidth) {
106 styledTextNode->getComputedConstraints().width =
108 - (parentNodeBorder.left + parentNodeBorder.right + parentNodePadding.left + parentNodePadding.right)
109 - (styledTextNodeBorder.left + styledTextNodeBorder.right + styledTextNodePadding.left + styledTextNodePadding.right);
113 const auto& styledTextNodeBorder = styledTextNode->getBorder();
114 const auto& styledTextNodePadding = styledTextNode->getPadding();
115 auto styledTextNodeAutoHeight = styledTextNode->getContentHeight();
116 auto parentNode = styledTextNode->getParentNode();
117 auto parentNodeHeight = parentNode->getComputedConstraints().height;
118 const auto& parentNodeBorder = parentNode->getBorder();
119 const auto& parentNodePadding = parentNode->getPadding();
120 if (parentNodeHeight > styledTextNodeAutoHeight) {
121 styledTextNode->getComputedConstraints().height =
123 - (parentNodeBorder.top + parentNodeBorder.bottom + parentNodePadding.top + parentNodePadding.bottom)
124 - (styledTextNodeBorder.top + styledTextNodeBorder.bottom + styledTextNodePadding.top + styledTextNodePadding.bottom);
132 auto released =
false;
133 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->node);
134 if (
node == styledTextNode) {
136 Vector2 nodeMouseCoordinateNoOffsets;
137 if (styledTextNode->isEventBelongingToNode(event, nodeMouseCoordinate) ==
true) {
138 nodeMouseCoordinateNoOffsets = nodeMouseCoordinate.
clone().
sub(
Vector2(styledTextNode->getParentNode()->getChildrenRenderOffsetX(), styledTextNode->getParentNode()->getChildrenRenderOffsetY()));
140 case GUIMouseEvent::MOUSEEVENT_PRESSED:
156 styledTextNode->setIndexMousePosition(nodeMouseCoordinateNoOffsets.
getX(), nodeMouseCoordinateNoOffsets.
getY());
160 event->setProcessed(
true);
165 case GUIMouseEvent::MOUSEEVENT_MOVED:
168 const auto& urlAreas = styledTextNode->getURLAreas();
170 for (
auto& urlArea: urlAreas) {
171 if (nodeMouseCoordinate.
getX() < urlArea.left ||
172 nodeMouseCoordinate.
getY() < urlArea.top ||
173 nodeMouseCoordinate.
getX() > urlArea.left + urlArea.width ||
174 nodeMouseCoordinate.
getY() > urlArea.top + urlArea.height) {
177 urlAreaHit = &urlArea;
180 Console::println(
"hand: " +
node->
getId() +
"(" + urlAreaHit->
url +
")");
184 if (urlAreaHit ==
nullptr) {
187 Console::println(
"normal: " +
node->
getId());
192 event->setProcessed(
true);
197 case GUIMouseEvent::MOUSEEVENT_RELEASED:
204 const auto& text = styledTextNode->getText();
205 auto textLength = text.length();
206 if (textLength > 0) {
207 auto wordLeftIdx = 0;
208 for (
auto i = 0; i <
index && i < textLength; i++) {
209 auto c = text.getUTF8CharAt(i);
210 if (Character::isAlphaNumeric(c) ==
false) {
214 auto wordRightIdx = textLength;
215 for (
auto i =
index; i < textLength; i++) {
216 auto c = text.getUTF8CharAt(i);
217 if (Character::isAlphaNumeric(c) ==
false) {
222 if (wordLeftIdx != wordRightIdx) {
233 styledTextNode->unsetIndexMousePosition();
234 styledTextNode->unsetSelectionIndexMousePosition();
237 styledTextNode->getScreenNode()->removeTickNode(styledTextNode);
252 styledTextNode->scrollToIndex();
259 const auto& urlAreas = styledTextNode->getURLAreas();
261 for (
auto& urlArea: urlAreas) {
262 if (nodeMouseCoordinate.
getX() < urlArea.left ||
263 nodeMouseCoordinate.
getY() < urlArea.top ||
264 nodeMouseCoordinate.
getX() > urlArea.left + urlArea.width ||
265 nodeMouseCoordinate.
getY() > urlArea.top + urlArea.height) {
268 urlAreaHit = &urlArea;
272 if (urlAreaHit !=
nullptr) {
274 if (StringTools::startsWith(urlAreaHit->
url,
"http://") ==
true || StringTools::startsWith(urlAreaHit->
url,
"https://") ==
true) {
275 Application::openBrowser(urlAreaHit->
url);
280 event->setProcessed(
true);
289 nodeMouseCoordinateNoOffsets = nodeMouseCoordinate.
clone().
sub(
Vector2(styledTextNode->getParentNode()->getChildrenRenderOffsetX(), styledTextNode->getParentNode()->getChildrenRenderOffsetY()));
293 case GUIMouseEvent::MOUSEEVENT_DRAGGED:
300 if (nodeMouseCoordinateNoOffsets.
getY() < 50) {
303 styledTextNode->unsetIndexMousePosition();
304 styledTextNode->unsetSelectionIndexMousePosition();
306 styledTextNode->getScreenNode()->addTickNode(styledTextNode);
308 if (nodeMouseCoordinateNoOffsets.
getY() > styledTextNode->getParentNode()->getComputedConstraints().height - 50) {
311 styledTextNode->unsetIndexMousePosition();
312 styledTextNode->unsetSelectionIndexMousePosition();
314 styledTextNode->getScreenNode()->addTickNode(styledTextNode);
316 styledTextNode->getScreenNode()->removeTickNode(styledTextNode);
320 styledTextNode->setSelectionIndexMousePosition(nodeMouseCoordinateNoOffsets.
getX(), nodeMouseCoordinateNoOffsets.
getY());
325 event->setProcessed(
true);
328 case GUIMouseEvent::MOUSEEVENT_RELEASED:
330 if (released ==
false) {
335 styledTextNode->unsetIndexMousePosition();
336 styledTextNode->unsetSelectionIndexMousePosition();
339 styledTextNode->getScreenNode()->removeTickNode(styledTextNode);
351 styledTextNode->scrollToIndex();
353 event->setProcessed(
true);
369 if (
input ==
false)
return;
373 auto disabled =
false;
374 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
375 if (disabled ==
false &&
377 event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_TYPED) {
378 event->setProcessed(
true);
381 if (event->
getKeyChar() ==
' ' || selection ==
true) {
385 if (selection ==
true) {
390 styledTextNode->scrollToIndex();
396 if (maxLength == 0 || styledTextNode->getTextLength() < maxLength) {
401 styledTextNode->scrollToIndex();
409 if (selection ==
true) {
417 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED)
redo();
418 event->setProcessed(
true);
421 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED)
undo();
422 event->setProcessed(
true);
426 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED)
selectAll();
427 event->setProcessed(
true);
430 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED)
cut();
431 event->setProcessed(
true);
434 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED)
copy();
435 event->setProcessed(
true);
438 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED)
paste();
439 event->setProcessed(
true);
443 event->setProcessed(
true);
447 case GUIKeyboardEvent::KEYCODE_LEFT: {
448 event->setProcessed(
true);
449 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
453 auto wordLeftIdx = -1;
454 auto lineStartIdx = styledTextNode->getPreviousNewLineUtf8(
index - 1);
455 if (lineStartIdx != 0) lineStartIdx++;
457 string delimiter =
"^´!\"§$%&/()=?`+#<,.-*'>;:_";
458 const auto& text = styledTextNode->getText();
459 auto textLength = text.length();
460 if (textLength > 0) {
461 wordLeftIdx = lineStartIdx;
463 for (; i >= lineStartIdx; i--) {
464 auto c = text.getUTF8CharAt(i);
465 if (Character::isAlphaNumeric(c) ==
true || delimiter.find(c) != string::npos)
break;
467 if (delimiter.find(text.getUTF8CharAt(i)) != string::npos) {
468 for (; i >= lineStartIdx && delimiter.find(text.getUTF8CharAt(i)) != string::npos; i--);
471 for (; i >= lineStartIdx; i--) {
472 auto c = text.getUTF8CharAt(i);
473 if (Character::isAlphaNumeric(c) ==
false || delimiter.find(c) != string::npos) {
487 if (wordLeftIdx == -1) {
492 styledTextNode->scrollToIndex();
500 case GUIKeyboardEvent::KEYCODE_RIGHT: {
501 event->setProcessed(
true);
502 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
506 auto wordRightIdx = -1;
508 string delimiter =
"^´!\"§$%&/()=?`+#<,.-*'>;:_";
509 const auto& text = styledTextNode->getText();
510 auto lineEndIdx = styledTextNode->getNextNewLineUtf8(
index);
511 if (lineEndIdx > 0) {
512 wordRightIdx = lineEndIdx;
514 for (; i < lineEndIdx; i++) {
515 auto c = text.getUTF8CharAt(i);
516 if (Character::isAlphaNumeric(c) ==
true || delimiter.find(c) != string::npos)
break;
518 if (delimiter.find(text.getUTF8CharAt(i)) != string::npos) {
519 for (; i < lineEndIdx && delimiter.find(text.getUTF8CharAt(i)) != string::npos; i++);
522 for (; i < lineEndIdx; i++) {
523 auto c = text.getUTF8CharAt(i);
524 if (Character::isAlphaNumeric(c) ==
false || delimiter.find(c) != string::npos) {
530 if (Character::isSpace(text.getUTF8CharAt(i)) ==
true) {
531 for (; i < lineEndIdx && Character::isSpace(text.getUTF8CharAt(i)) ==
true; i++);
541 if (index < styledTextNode->getTextLength()) {
542 if (wordRightIdx == -1) {
545 index = wordRightIdx;
547 styledTextNode->scrollToIndex();
555 case GUIKeyboardEvent::KEYCODE_UP: {
556 event->setProcessed(
true);
557 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
567 const auto& text = styledTextNode->getText();
569 auto lineNewLineIndex = styledTextNode->getPreviousNewLineUtf8(
index);
570 if (lineNewLineIndex ==
index) lineNewLineIndex = styledTextNode->getPreviousNewLineUtf8(
index - 1);
575 for (
auto i = lineNewLineIndex; i <
index; i++) {
576 if (text.getUTF8CharAt(i) ==
'\t')
lineIndex+= 3;
585 auto previousNewLineIndex = styledTextNode->getPreviousNewLineUtf8(styledTextNode->getPreviousNewLineUtf8(
index - 1) - 1);
586 if (previousNewLineIndex != 0) previousNewLineIndex++;
588 auto nextNewLineIndex = styledTextNode->getNextNewLineUtf8(previousNewLineIndex);
590 index = previousNewLineIndex;
592 if (text.getUTF8CharAt(
index) ==
'\t') i+= 4;
else i+= 1;
596 styledTextNode->scrollToIndex();
603 case GUIKeyboardEvent::KEYCODE_DOWN: {
604 event->setProcessed(
true);
605 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
615 const auto& text = styledTextNode->getText();
617 auto lineNewLineIndex = styledTextNode->getPreviousNewLineUtf8(
index);
618 if (lineNewLineIndex ==
index) lineNewLineIndex = styledTextNode->getPreviousNewLineUtf8(
index - 1);
623 for (
auto i = lineNewLineIndex; i <
index; i++) {
624 if (text.getUTF8CharAt(i) ==
'\t')
lineIndex+= 3;
633 auto nextNewLineIndex = styledTextNode->getNextNewLineUtf8(
index);
635 auto next2NewLineIndex = styledTextNode->getNextNewLineUtf8(nextNewLineIndex + 1);
637 index = nextNewLineIndex + 1;
639 if (text.getUTF8CharAt(
index) ==
'\t') i+= 4;
else i+= 1;
643 styledTextNode->scrollToIndex();
650 case GUIKeyboardEvent::KEYCODE_PAGE_UP: {
651 event->setProcessed(
true);
652 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
661 index = styledTextNode->doPageUp();
668 case GUIKeyboardEvent::KEYCODE_PAGE_DOWN: {
669 event->setProcessed(
true);
670 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
679 index = styledTextNode->doPageDown();
686 case GUIKeyboardEvent::KEYCODE_BACKSPACE: {
687 if (disabled ==
false) {
688 event->setProcessed(
true);
689 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
696 styledTextNode->scrollToIndex();
703 styledTextNode->removeText(
index - 1, 1);
704 styledTextNode->scrollToIndex();
715 case GUIKeyboardEvent::KEYCODE_DELETE: {
716 if (disabled ==
false) {
717 event->setProcessed(
true);
718 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
724 case GUIKeyboardEvent::KEYCODE_RETURN: {
725 if (disabled ==
false) {
726 event->setProcessed(
true);
727 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
731 string newLinePrefix;
733 const auto& text = styledTextNode->getText();
734 auto lineNewLineIndex = styledTextNode->getPreviousNewLineUtf8(
index);
735 if (lineNewLineIndex ==
index) lineNewLineIndex = styledTextNode->getPreviousNewLineUtf8(
index - 1);
738 for (
auto i = lineNewLineIndex; i <
index; i++) {
739 auto c = text.getUTF8CharAt(i);
740 if (c ==
' ' || c ==
'\t') {
741 newLinePrefix+= (char)c;
750 styledTextNode->scrollToIndex();
755 if (maxLength == 0 || styledTextNode->getTextLength() < maxLength) {
757 styledTextNode->insertText(
index,
'\n' + newLinePrefix);
758 styledTextNode->scrollToIndex();
760 index+= 1 + newLinePrefix.size();
772 case GUIKeyboardEvent::KEYCODE_TAB: {
773 if (disabled ==
false) {
774 event->setProcessed(
true);
775 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
779 if ((maxLength == 0 || styledTextNode->getTextLength() + 1 < maxLength) &&
783 styledTextNode->insertText(lineNewLineIndex,
'\t');
788 auto nextNewLineIndex = lineNewLineIndex;
791 nextNewLineIndex = styledTextNode->getNextNewLineUtf8(nextNewLineIndex) + 1;
792 styledTextNode->insertText(nextNewLineIndex,
'\t');
797 if (styledTextNode->getTextLength() >= maxLength)
break;
800 if ((maxLength == 0 || styledTextNode->getTextLength() < maxLength) &&
805 styledTextNode->insertText(
index,
'\t');
806 styledTextNode->scrollToIndex();
817 case GUIKeyboardEvent::KEYCODE_POS1: {
818 if (disabled ==
false) {
819 event->setProcessed(
true);
820 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
834 index = styledTextNode->getPreviousNewLineUtf8(
index - 1);
838 styledTextNode->scrollToIndex();
845 case GUIKeyboardEvent::KEYCODE_END: {
846 if (disabled ==
false) {
847 if (event->
getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
858 index = styledTextNode->getTextLength() - 1;
861 index = styledTextNode->getNextNewLineUtf8(
index);;
863 styledTextNode->scrollToIndex();
877 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
884 auto previousNewLineIndex = styledTextNode->getPreviousNewLineUtf8(styledTextNode->getPreviousNewLineUtf8(
selectionIndex - 1) - 1);
885 if (previousNewLineIndex != 0) previousNewLineIndex++;
887 auto nextNewLineIndex = styledTextNode->getNextNewLineUtf8(previousNewLineIndex);
891 styledTextNode->scrollToSelectionIndex();
899 auto nextNewLineIndex = styledTextNode->getNextNewLineUtf8(
selectionIndex);
901 auto next2NewLineIndex = styledTextNode->getNextNewLineUtf8(nextNewLineIndex + 1);
905 styledTextNode->scrollToSelectionIndex();
924 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
925 return styledTextNode->getText();
930 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
931 styledTextNode->setText(value);
960 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
961 const auto& text = styledTextNode->getText();
962 auto u8It = text.getUTF8CharacterIterator();
963 u8It.seekCharacterPosition(idx);
964 auto binaryStartIdx = u8It.getBinaryPosition();
965 for (
auto i = 0; u8It.hasNext() ==
true && i < count; i++) u8It.next();
966 auto binaryEndIdx = u8It.getBinaryPosition();
969 changeListeners[i]->onRemoveText(binaryStartIdx, binaryEndIdx - binaryStartIdx);
975 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
976 const auto& text = styledTextNode->getText();
977 auto u8It = text.getUTF8CharacterIterator();
978 u8It.seekCharacterPosition(idx);
979 auto binaryStartIdx = u8It.getBinaryPosition();
980 for (
auto i = 0; u8It.hasNext() ==
true && i < count; i++) u8It.next();
981 auto binaryEndIdx = u8It.getBinaryPosition();
985 changeListeners[i]->onInsertText(binaryStartIdx, binaryEndIdx - binaryStartIdx);
990 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
991 const auto& text = styledTextNode->getText();
992 auto binaryIdx = text.getUtf8BinaryIndex(idx);
999 Console::println(
"GUIStyledTextNodeController::storeTypingHistoryEntry()");
1031 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1032 const auto& text = styledTextNode->getText();
1033 auto u8It = text.getUTF8CharacterIterator();
1036 for (; u8It.hasNext() ==
true && u8It.getCharacterPosition() <
index;) Character::appendToString(data, u8It.next());
1051 const auto& historyEntry =
history[i];
1052 string historyEntryTypeString;
1053 switch (historyEntry.type) {
1055 historyEntryTypeString =
"NONE";
1058 historyEntryTypeString =
"INSERT";
1061 historyEntryTypeString =
"DELETE";
1065 Console::println(
"GUIStyledTextNodeController::storeTypingHistoryEntry(): " + to_string(i) +
": history entry @ " + to_string(historyEntry.idx) +
": '" + historyEntry.data +
"'" +
": " + historyEntryTypeString);
1070 Console::println(
"GUIStyledTextNodeController::storeTypingHistoryEntry2()");
1093 const auto& historyEntry =
history[i];
1094 string historyEntryTypeString;
1095 switch (historyEntry.type) {
1097 historyEntryTypeString =
"NONE";
1100 historyEntryTypeString =
"INSERT";
1103 historyEntryTypeString =
"DELETE";
1107 Console::println(
"GUIStyledTextNodeController::storeTypingHistoryEntry2(): " + to_string(i) +
": history entry @ " + to_string(historyEntry.idx) +
": '" + historyEntry.data +
"'" +
": " + historyEntryTypeString);
1112 Console::println(
"GUIStyledTextNodeController::storeDeletionHistoryInternal(): " + to_string(
index) +
" / " + to_string(count));
1114 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1115 const auto& text = styledTextNode->getText();
1116 auto u8It = text.getUTF8CharacterIterator();
1117 u8It.seekCharacterPosition(
index);
1119 for (
auto i = 0; u8It.hasNext() ==
true && i < count; i++) Character::appendToString(data, u8It.next());
1131 const auto& historyEntry =
history[i];
1132 string historyEntryTypeString;
1133 switch (historyEntry.type) {
1135 historyEntryTypeString =
"NONE";
1138 historyEntryTypeString =
"INSERT";
1141 historyEntryTypeString =
"DELETE";
1145 Console::println(
"GUIStyledTextNodeController::storeDeletionHistoryInternal(): " + to_string(i) +
": history entry @ " + to_string(historyEntry.idx) +
": '" + historyEntry.data +
"'" +
": " + historyEntryTypeString);
1155 Console::println(
"GUIStyledTextNodeController::redo(): " + to_string(
historyIdx) +
" / " + to_string(
history.size()));
1158 if (
history.empty() ==
true)
return;
1170 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1171 switch (historyEntry.type) {
1174 auto dataUtf8Length = StringTools::getUtf8Length(historyEntry.data);
1175 index = historyEntry.idx;
1177 styledTextNode->insertText(
index, historyEntry.data);
1179 index+= dataUtf8Length;
1184 index = historyEntry.idx;
1186 auto dataUtf8Length = StringTools::getUtf8Length(historyEntry.data);
1187 styledTextNode->removeText(
index, dataUtf8Length);
1198 styledTextNode->scrollToIndex();
1209 if (
history.empty() ==
true)
return;
1221 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1224 switch (historyEntry.type) {
1227 index = historyEntry.idx;
1229 auto dataUtf8Length = StringTools::getUtf8Length(historyEntry.data);
1230 styledTextNode->removeText(
index, dataUtf8Length);
1236 auto dataUtf8Length = StringTools::getUtf8Length(historyEntry.data);
1237 index = historyEntry.idx;
1239 styledTextNode->insertText(
index, historyEntry.data);
1241 index+= dataUtf8Length;
1248 styledTextNode->scrollToIndex();
1252 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1253 const auto& text = styledTextNode->getText();
1263 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1264 const auto& text = styledTextNode->getText();
1265 Application::getApplication()->setClipboardContent(StringTools::substring(text.getString(), Math::min(text.getUtf8BinaryIndex(
index), text.getUtf8BinaryIndex(
selectionIndex)), Math::max(text.getUtf8BinaryIndex(
index), text.getUtf8BinaryIndex(
selectionIndex))));
1268 styledTextNode->scrollToIndex();
1279 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1280 const auto& text = styledTextNode->getText();
1281 Application::getApplication()->setClipboardContent(StringTools::substring(text.getString(), Math::min(text.getUtf8BinaryIndex(
index), text.getUtf8BinaryIndex(
selectionIndex)), Math::max(text.getUtf8BinaryIndex(
index), text.getUtf8BinaryIndex(
selectionIndex))));
1289 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1291 auto clipboardContent = Application::getApplication()->getClipboardContent();
1292 auto clipboardContentLength = StringTools::getUtf8Length(clipboardContent);
1294 if (maxLength == 0 || styledTextNode->getTextLength() - Math::abs(
index -
selectionIndex) + clipboardContentLength < maxLength) {
1297 styledTextNode->scrollToIndex();
1304 if (maxLength == 0 || styledTextNode->getTextLength() + clipboardContentLength < maxLength) {
1309 styledTextNode->insertText(
index, clipboardContent);
1310 styledTextNode->scrollToIndex();
1312 index+= clipboardContentLength;
1324 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1328 styledTextNode->scrollToIndex();
1333 if (index < styledTextNode->getTextLength()) {
1335 styledTextNode->removeText(
index, 1);
1336 styledTextNode->scrollToIndex();
1345 auto styledTextNode = required_dynamic_cast<GUIStyledTextNode*>(this->
node);
1350 styledTextNode->removeText(
index, count);
1354 styledTextNode->insertText(
index, by);
#define MOUSE_CURSOR_HAND
#define MOUSE_CURSOR_ENABLED
Application base class, please make sure to allocate application on heap to have correct application ...
void addMouseOutCandidateNode(GUINode *node)
Add node that is a possible mouse out candidate as it received a mouse over.
int32_t getKeyCode() const
bool isControlDown() const
int32_t getKeyChar() const
GUIKeyboardEventType getType() const
GUIMouseEventType getType() const
GUI node controller base class.
static STATIC_DLL_IMPEXT GUINode_RequestedConstraints_RequestedConstraintsType * AUTO
GUIParentNode * getParentControllerNode()
GUIScreenNode * getScreenNode()
GUI styled text node controller.
static constexpr int64_t CURSOR_MODE_DURATION
void onFocusGained() override
On focus gained.
void dispose() override
Dispose controller.
void storeTypingHistoryEntry()
Store typing history entry.
void replace(const string &by, int index, int count)
Replace text from given index with given count by string by.
void storeDeletionHistoryEntry(int index, int count)
Store deletion history entry.
void postLayout() override
Post layout event.
void resetCursorMode()
Reset cursor mode.
void initialize() override
Initialize controller after element has been created.
void handleKeyboardEvent(GUIKeyboardEvent *event) override
Handle keyboard event.
void setIndex(int index)
Set index.
void storeDeletionHistoryEntryStoreTypingEntry(int index, int count)
Store deletion history entry and store prior typing if we have any.
void onFocusLost() override
On focus lost.
void setValue(const MutableString &value) override
Set value.
void handleMouseEvent(GUINode *node, GUIMouseEvent *event) override
Handle mouse event.
void addCodeCompletionListener(CodeCompletionListener *listener)
Add code completion listener.
void tick() override
Tick method will be executed once per frame.
void forwardInsertText(int idx, int count)
Forward insert text.
vector< HistoryEntry > history
void unsetTypingHistoryEntryIdx()
Unset typing history entry index.
void setTypingHistoryEntryIdx()
Set typing history entry index.
void setDisabled(bool disabled) override
Set disabled.
void addChangeListener(ChangeListener *listener)
Add change listener.
void storeDeletionHistoryInternal(int index, int count)
Store typing history entry.
void removeCodeCompletionListener(CodeCompletionListener *listener)
Remove code completion listener.
void storeTypingHistoryEntry2(int index, const string &data)
Store typing history entry.
void selectAll()
Select all.
const MutableString & getValue() override
void removeChangeListener(ChangeListener *listener)
Remove change listener.
int64_t cursorModeStarted
vector< ChangeListener * > changeListeners
bool isDisabled() override
void onSubTreeChange() override
On sub tree change.
void forwardRemoveText(int idx, int count)
Forward remove text.
vector< CodeCompletionListener * > codeCompletionListeners
void setSelectionIndex(int selectionIndex)
Set selection index.
CursorMode getCursorMode()
void forwardCodeCompletion(int idx)
Forward code completion.
static constexpr int64_t TIME_DOUBLECLICK
Vector2 class representing vector2 mathematical structure and operations with x, y components.
Vector2 & sub(float scalar)
Subtracts a scalar.
Vector2 clone() const
Clones this vector2.
Mutable utf8 aware string class.
Change listener interface.
Code completion listener.