693 | function TextInputElement:draw(clipX1, clipY1, clipX2, clipY2) |
694 | -- call ancestor drawing functions with empty text: |
695 | local text = self.text |
696 | self.text = "" |
697 | TextInputElement:superClass().draw(self, clipX1, clipY1, clipX2, clipY2) |
698 | self.text = text |
699 | |
700 | setTextAlignment(self.textAlignment) |
701 | local neededWidth = self:getNeededTextWidth() |
702 | |
703 | local textXPos = self.absPosition[1] + self.textOffset[1] |
704 | if self.textAlignment == RenderText.ALIGN_CENTER then |
705 | textXPos = textXPos + (self.maxInputTextWidth * 0.5) - (neededWidth * 0.5) |
706 | elseif self.textAlignment == RenderText.ALIGN_RIGHT then |
707 | textXPos = textXPos + self.maxInputTextWidth - neededWidth |
708 | end |
709 | textXPos = textXPos + (self.size[1]-self.maxInputTextWidth) / 2 |
710 | |
711 | local _, yOffset = self:getTextOffset() |
712 | local _, yPos = self:getTextPosition(self.text) |
713 | local textYPos = yPos + yOffset |
714 | |
715 | if clipX1 ~= nil then |
716 | setTextClipArea(clipX1, clipY1, clipX2, clipY2) |
717 | end |
718 | |
719 | local displacementX = 0 |
720 | if self.areFrontDotsVisible then |
721 | local additionalDisplacement = self:drawTextPart(self.frontDotsText, textXPos, displacementX, textYPos) |
722 | displacementX = displacementX + additionalDisplacement |
723 | end |
724 | if self.isVisibleTextPart1Visible then |
725 | local additionalDisplacement = self:drawTextPart(self.visibleTextPart1, textXPos, displacementX, textYPos) |
726 | displacementX = displacementX + additionalDisplacement |
727 | end |
728 | if self.isCursorVisible then |
729 | local additionalDisplacement = self:drawCursor(textXPos, displacementX, textYPos) |
730 | displacementX = displacementX + additionalDisplacement |
731 | end |
732 | if self.isVisibleTextPart2Visible then |
733 | local additionalDisplacement = self:drawTextPart(self.visibleTextPart2, textXPos, displacementX, textYPos) |
734 | displacementX = displacementX + additionalDisplacement |
735 | end |
736 | |
737 | if self.areBackDotsVisible then |
738 | self:drawTextPart(self.backDotsText, textXPos, displacementX, textYPos) |
739 | end |
740 | |
741 | setTextBold(false) |
742 | setTextAlignment(RenderText.ALIGN_LEFT) |
743 | setTextColor(1, 1, 1, 1) |
744 | |
745 | if clipX1 ~= nil then |
746 | setTextClipArea(0, 0, 1, 1) |
747 | end |
748 | end |
515 | function TextInputElement:keyEvent(unicode, sym, modifier, isDown, eventUsed) |
516 | if TextInputElement:superClass().keyEvent(self, unicode, sym, modifier, isDown, eventUsed) then |
517 | eventUsed = true |
518 | end |
519 | |
520 | if self.isRepeatingSpecialKeyDown and not isDown and self.repeatingSpecialKeySym == sym then |
521 | self:stopSpecialKeyRepeating() |
522 | end |
523 | |
524 | if self.blockTime <= 0 and self:getIsActive() and self:getOverlayState() == GuiOverlay.STATE_PRESSED then |
525 | local wasSpecialKey = false |
526 | |
527 | if not isDown then |
528 | -- react to input state-changing keys on key "up" to avoid double inputs in the menu |
529 | if sym == Input.KEY_return and self.isReturnDown then |
530 | self.isReturnDown = false |
531 | self:setForcePressed(not self.forcePressed) |
532 | self:raiseCallback("onEnterPressedCallback", self) |
533 | elseif sym == Input.KEY_esc then |
534 | self.isEscDown = false |
535 | self:setForcePressed(not self.forcePressed) |
536 | self:raiseCallback("onEscPressedCallback", self) |
537 | end |
538 | else |
539 | local startSpecialKeyRepeating = false |
540 | if sym == Input.KEY_left then |
541 | --self.cursorPosition = math.max(1, self.cursorPosition - 1) |
542 | -- is now handled by Focus system |
543 | self:moveCursorLeft() |
544 | startSpecialKeyRepeating = true |
545 | wasSpecialKey = true |
546 | elseif sym == Input.KEY_right then |
547 | --self.cursorPosition = math.min(utf8Strlen(self.text) + 1, self.cursorPosition + 1) |
548 | -- is now handled by focus system |
549 | self:moveCursorRight() |
550 | startSpecialKeyRepeating = true |
551 | wasSpecialKey = true |
552 | elseif sym == Input.KEY_home then |
553 | self.cursorPosition = 1 |
554 | wasSpecialKey = true |
555 | elseif sym == Input.KEY_end then |
556 | self.cursorPosition = utf8Strlen(self.text) + 1 |
557 | wasSpecialKey = true |
558 | elseif sym == Input.KEY_delete then |
559 | self:deleteText(true) |
560 | startSpecialKeyRepeating = true |
561 | wasSpecialKey = true |
562 | elseif sym == Input.KEY_backspace then |
563 | self:deleteText(false) |
564 | startSpecialKeyRepeating = true |
565 | wasSpecialKey = true |
566 | elseif sym == Input.KEY_esc then |
567 | self.isEscDown = true |
568 | wasSpecialKey = true |
569 | elseif sym == Input.KEY_return then |
570 | self.isReturnDown = true |
571 | wasSpecialKey = true |
572 | end |
573 | |
574 | if startSpecialKeyRepeating then |
575 | self.isRepeatingSpecialKeyDown = true |
576 | self.repeatingSpecialKeySym = sym |
577 | self.repeatingSpecialKeyDelayTime = TextInputElement.INITIAL_REPEAT_DELAY |
578 | self.repeatingSpecialKeyRemainingDelayTime = self.repeatingSpecialKeyDelayTime |
579 | end |
580 | |
581 | if not wasSpecialKey then |
582 | if self:getIsUnicodeAllowed(unicode) then |
583 | local textLength = utf8Strlen(self.text) |
584 | if self.maxCharacters == nil or textLength < self.maxCharacters then |
585 | self.text = |
586 | ((self.cursorPosition > 1) and utf8Substr(self.text, 0, self.cursorPosition - 1) or "") .. |
587 | unicodeToUtf8(unicode) .. |
588 | ((self.cursorPosition <= textLength) and utf8Substr(self.text, self.cursorPosition - 1) or "") |
589 | |
590 | self.cursorPosition = self.cursorPosition + 1 |
591 | |
592 | self:raiseCallback("onTextChangedCallback", self, self.text) |
593 | end |
594 | end |
595 | end |
596 | |
597 | self:updateVisibleTextElements() |
598 | |
599 | eventUsed = true |
600 | end |
601 | end |
602 | |
603 | return eventUsed |
604 | end |
105 | function TextInputElement:loadFromXML(xmlFile, key) |
106 | TextInputElement:superClass().loadFromXML(self, xmlFile, key) |
107 | |
108 | self:addCallback(xmlFile, key.."#onEnter", "onEnterCallback") |
109 | self:addCallback(xmlFile, key.."#onTextChanged", "onTextChangedCallback") |
110 | self:addCallback(xmlFile, key.."#onEnterPressed", "onEnterPressedCallback") |
111 | self:addCallback(xmlFile, key.."#onEscPressed", "onEscPressedCallback") |
112 | self:addCallback(xmlFile, key.."#onIsUnicodeAllowed", "onIsUnicodeAllowedCallback") |
113 | |
114 | self.imeKeyboardType = Utils.getNoNil(getXMLString(xmlFile, key.."#imeKeyboardType"), self.imeKeyboardType) |
115 | self.imeTitle = self:translate(getXMLString(xmlFile, key.."#imeTitle")) |
116 | self.imeDescription = self:translate(getXMLString(xmlFile, key.."#imeDescription")) |
117 | self.imePlaceholder = self:translate(getXMLString(xmlFile, key.."#imePlaceholder")) |
118 | |
119 | self.maxCharacters = Utils.getNoNil(getXMLInt(xmlFile, key.."#maxCharacters"), self.maxCharacters) |
120 | self.maxInputTextWidth = unpack(GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#maxInputTextWidth"), {self.outputSize[1]}, {self.maxInputTextWidth})) |
121 | self.cursorOffset = GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#cursorOffset"), self.outputSize, self.cursorOffset) |
122 | self.cursorSize = GuiUtils.getNormalizedValues(getXMLString(xmlFile, key.."#cursorSize"), self.outputSize, self.cursorSize) |
123 | |
124 | if g_screenWidth > 1 then |
125 | self.cursorSize[1] = math.max(self.cursorSize[1], 1 / g_screenWidth) |
126 | end |
127 | |
128 | self.enterWhenClickOutside = Utils.getNoNil(getXMLBool(xmlFile, key .. "#enterWhenClickOutside"), self.enterWhenClickOutside) |
129 | |
130 | GuiOverlay.loadOverlay(self, self.cursor, "cursor", self.imageSize, nil, xmlFile, key) |
131 | GuiOverlay.createOverlay(self.cursor) |
132 | |
133 | self.isPassword = Utils.getNoNil(getXMLBool(xmlFile, key .. "#isPassword"), self.isPassword) |
134 | |
135 | self:finalize() |
136 | end |
365 | function TextInputElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) |
366 | if self:getIsActive() then |
367 | local isCursorInside = GuiUtils.checkOverlayOverlap(posX, posY, self.absPosition[1], self.absPosition[2], self.size[1], self.size[2]) |
368 | |
369 | if not self.forcePressed then |
370 | if eventUsed then |
371 | self:setOverlayState(GuiOverlay.STATE_NORMAL) |
372 | end |
373 | |
374 | if not eventUsed and isCursorInside and not FocusManager:isLocked() then |
375 | FocusManager:setHighlight(self) |
376 | |
377 | eventUsed = true |
378 | if self:getOverlayState() == GuiOverlay.STATE_NORMAL then |
379 | self:setOverlayState(GuiOverlay.STATE_FOCUSED) |
380 | end |
381 | |
382 | if isDown and button == Input.MOUSE_BUTTON_LEFT then |
383 | self.textInputMouseDown = true |
384 | |
385 | if not self.useIme then |
386 | self:setOverlayState(GuiOverlay.STATE_PRESSED) |
387 | end |
388 | end |
389 | |
390 | if isUp and button == Input.MOUSE_BUTTON_LEFT and self.textInputMouseDown then |
391 | self.textInputMouseDown = false |
392 | |
393 | self:setOverlayState(GuiOverlay.STATE_PRESSED) |
394 | self:setForcePressed(true) |
395 | if self.useIme then |
396 | self:openIme() |
397 | end |
398 | end |
399 | else |
400 | if (isDown and button == Input.MOUSE_BUTTON_LEFT) or self.textInputMouseDown or self:getOverlayState() ~= GuiOverlay.STATE_PRESSED then |
401 | FocusManager:unsetHighlight(self) |
402 | end |
403 | |
404 | self.textInputMouseDown = false |
405 | end |
406 | elseif self.enterWhenClickOutside then |
407 | if not isCursorInside and isUp and button == Input.MOUSE_BUTTON_LEFT then |
408 | -- Dismiss when clicking outside of the box |
409 | self:abortIme() |
410 | self:setForcePressed(false) |
411 | |
412 | |
413 | self:raiseCallback("onEnterPressedCallback", self, true) |
414 | end |
415 | end |
416 | |
417 | if not eventUsed then |
418 | eventUsed = TextInputElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) |
419 | end |
420 | end |
421 | |
422 | return eventUsed |
423 | end |
38 | function TextInputElement.new(target, custom_mt) |
39 | local self = ButtonElement.new(target, custom_mt or TextInputElement_mt) |
40 | |
41 | self.textInputMouseDown = false |
42 | self.forcePressed = false |
43 | self.isPassword = false |
44 | self.displayText = "" -- actually displayed text, masked if this is a password input field |
45 | self.cursor = {} |
46 | self.cursorBlinkTime = 0 |
47 | self.cursorBlinkInterval = 400 |
48 | self.cursorOffset = {0,0} |
49 | self.cursorSize = {0.0016, 0.018} |
50 | self.cursorNeededSize = { |
51 | self.cursorOffset[1] + self.cursorSize[1], |
52 | self.cursorOffset[2] + self.cursorSize[2] |
53 | } |
54 | self.cursorPosition = 1 |
55 | self.firstVisibleCharacterPosition = 1 |
56 | self.lastVisibleCharacterPosition = 1 |
57 | self.maxCharacters = nil |
58 | self.maxInputTextWidth = nil |
59 | self.frontDotsText = "..." |
60 | self.backDotsText = "..." |
61 | self.text = "" |
62 | self.useIme = imeIsSupported() |
63 | self.preImeText = "" |
64 | self.imeActive = false |
65 | self.blockTime = 0 |
66 | |
67 | self.isReturnDown = false |
68 | self.isEscDown = false |
69 | self.isCapturingInput = false |
70 | self.hadFocusOnCapture = false |
71 | self.enterWhenClickOutside = true |
72 | |
73 | -- Handle hightlight on focused elements differently: if highlight is removed, |
74 | -- do not change focus. |
75 | self.disallowFocusedHighlight = true |
76 | |
77 | self.imeKeyboardType = "normal" |
78 | |
79 | self.forceFocus = true |
80 | |
81 | self.customFocusSample = GuiSoundPlayer.SOUND_SAMPLES.TEXTBOX |
82 | |
83 | return self |
84 | end |
238 | function TextInputElement:setCaptureInput(isCapturing) |
239 | self.blockTime = 200 |
240 | if not self.isCapturingInput and isCapturing then |
241 | -- reset control key flags to avoid immediately returning out of edit mode: |
242 | self.isReturnDown = false |
243 | self.isEscDown = false |
244 | |
245 | self.target:disableInputForDuration(0) |
246 | |
247 | if TextInputElement.inputContextActive then |
248 | -- Special case handling for mouse click activation of text input elements. Because of the call order, |
249 | -- another text element may previously have been active when this one has been activated by click. Avoid |
250 | -- corrupting the input context by reverting here first. |
251 | g_inputBinding:revertContext(true) |
252 | end |
253 | |
254 | g_inputBinding:setContext(TextInputElement.INPUT_CONTEXT_NAME, true, false) |
255 | TextInputElement.inputContextActive = true |
256 | |
257 | if not GS_IS_CONSOLE_VERSION then |
258 | -- Special case handling for gaming stations which do not have keyboards available for players: |
259 | -- Register menu back and accept actions so players can exit text boxes with gamepads using either input, |
260 | -- by default bound to buttons "A" for accept and "B" for back. |
261 | g_inputBinding:registerActionEvent(InputAction.MENU_BACK, self, self.inputEvent, false, true, false, true) |
262 | g_inputBinding:registerActionEvent(InputAction.MENU_ACCEPT, self, self.inputEvent, false, true, false, true) |
263 | end |
264 | |
265 | self.isCapturingInput = true |
266 | elseif self.isCapturingInput and not isCapturing then |
267 | if TextInputElement.inputContextActive then |
268 | -- Special case handling for mouse click activation of text input elements. Ensure to avoid double reverts |
269 | -- when switching from one text input to another. |
270 | g_inputBinding:revertContext(true) -- revert and clear text input context |
271 | TextInputElement.inputContextActive = false |
272 | end |
273 | |
274 | self.target:disableInputForDuration(200) |
275 | self.isCapturingInput = false |
276 | end |
277 | end |
638 | function TextInputElement:update(dt) |
639 | TextInputElement:superClass().update(self, dt) |
640 | |
641 | self.cursorBlinkTime = self.cursorBlinkTime+dt |
642 | while self.cursorBlinkTime > 2*self.cursorBlinkInterval do |
643 | self.cursorBlinkTime = self.cursorBlinkTime - 2*self.cursorBlinkInterval |
644 | end |
645 | |
646 | if self.isRepeatingSpecialKeyDown then |
647 | self.repeatingSpecialKeyRemainingDelayTime = self.repeatingSpecialKeyRemainingDelayTime - dt |
648 | if self.repeatingSpecialKeyRemainingDelayTime <= 0 then |
649 | if self.repeatingSpecialKeySym == Input.KEY_left then |
650 | self:moveCursorLeft() |
651 | elseif self.repeatingSpecialKeySym == Input.KEY_right then |
652 | self:moveCursorRight() |
653 | elseif self.repeatingSpecialKeySym == Input.KEY_delete then |
654 | self:deleteText(true) |
655 | elseif self.repeatingSpecialKeySym == Input.KEY_backspace then |
656 | self:deleteText(false) |
657 | end |
658 | self:updateVisibleTextElements() |
659 | |
660 | -- reduce key delay each frame down to the minimum to accelerate input when holding control keys |
661 | self.repeatingSpecialKeyDelayTime = math.max(TextInputElement.MIN_REPEAT_DELAY, (self.repeatingSpecialKeyDelayTime or TextInputElement.INITIAL_REPEAT_DELAY) * (0.1^(dt/100))) |
662 | self.repeatingSpecialKeyRemainingDelayTime = self.repeatingSpecialKeyDelayTime |
663 | end |
664 | end |
665 | if self.useIme and self.imeActive then |
666 | local done,cancel = imeIsComplete() |
667 | if done then |
668 | self.imeActive = false |
669 | |
670 | self:setForcePressed(false) |
671 | if not cancel then |
672 | self:setText(imeGetLastString()) |
673 | self:raiseCallback("onEnterPressedCallback", self) |
674 | else |
675 | self:setText(self.preImeText) |
676 | self.preImeText = "" |
677 | self:raiseCallback("onEscPressedCallback", self) |
678 | end |
679 | else |
680 | self:setText(imeGetLastString()) |
681 | self:setCursorPosition(imeGetCursorPos()+1) |
682 | self:updateVisibleTextElements() |
683 | end |
684 | end |
685 | |
686 | if self.blockTime > 0 then |
687 | self.blockTime = self.blockTime - dt |
688 | end |
689 | end |
835 | function TextInputElement:updateVisibleTextElements() |
836 | self.isCursorVisible = false |
837 | self.isVisibleTextPart1Visible = false |
838 | self.visibleTextPart1 = "" |
839 | self.isVisibleTextPart2Visible = false |
840 | self.visibleTextPart2 = "" |
841 | |
842 | self.areFrontDotsVisible = false |
843 | self.areBackDotsVisible = false |
844 | |
845 | self.firstVisibleCharacterPosition = 1 |
846 | |
847 | setTextBold(self.textBold) |
848 | |
849 | local displayText = self.text |
850 | if self.isPassword then |
851 | displayText = string.rep("*", utf8Strlen(self.text)) |
852 | end |
853 | |
854 | local textLength = utf8Strlen(displayText) |
855 | local availableTextWidth = self:getAvailableTextWidth() |
856 | |
857 | if self:getIsActive() and self:getOverlayState() == GuiOverlay.STATE_PRESSED then |
858 | -- input is gathered, cursor is shown, |
859 | -- text is displayed at an arbitrary position, both additonal text markers may be displayed |
860 | |
861 | self.isCursorVisible = true |
862 | |
863 | if self.cursorPosition < self.firstVisibleCharacterPosition then |
864 | -- cursor was moved to the left to display additional text |
865 | self.firstVisibleCharacterPosition = self.cursorPosition |
866 | end |
867 | |
868 | if self.firstVisibleCharacterPosition > 1 then |
869 | self.areFrontDotsVisible = true |
870 | end |
871 | |
872 | local textInvisibleFrontTrimmed = utf8Substr(displayText, self.firstVisibleCharacterPosition-1) |
873 | local textWidthInvisibleFrontTrimmed = getTextWidth(self.textSize, textInvisibleFrontTrimmed) |
874 | availableTextWidth = self:getAvailableTextWidth() |
875 | |
876 | if availableTextWidth and textWidthInvisibleFrontTrimmed > availableTextWidth then |
877 | -- not all text fits into the visible area |
878 | if self.cursorPosition <= textLength then |
879 | -- the cursor is not at the last position of the text |
880 | --self.isBackAdditionalTextMarkerVisible = true |
881 | self.areBackDotsVisible = true |
882 | availableTextWidth = self:getAvailableTextWidth() |
883 | end |
884 | end |
885 | |
886 | |
887 | local visibleText = TextInputElement.limitTextToAvailableWidth(textInvisibleFrontTrimmed, self.textSize, availableTextWidth) |
888 | local visibleTextWidth = getTextWidth(self.textSize, visibleText) |
889 | local visibleTextLength = utf8Strlen(visibleText) |
890 | |
891 | if availableTextWidth and self.cursorPosition > self.firstVisibleCharacterPosition + visibleTextLength then |
892 | -- the cursor is on the right side and not visible anymore |
893 | -- text has to be shifted for the cursor to become visible again |
894 | --self.isFrontAdditionalTextMarkerVisible = true |
895 | self.areFrontDotsVisible = true |
896 | availableTextWidth = self:getAvailableTextWidth() |
897 | |
898 | local textTrimmedAtCursor = utf8Substr(textInvisibleFrontTrimmed, 0, self.cursorPosition - self.firstVisibleCharacterPosition) |
899 | visibleText = TextInputElement.limitTextToAvailableWidth( |
900 | textTrimmedAtCursor, self.textSize, availableTextWidth, true) |
901 | visibleTextWidth = getTextWidth(self.textSize, visibleText) |
902 | visibleTextLength = utf8Strlen(visibleText) |
903 | self.firstVisibleCharacterPosition = self.cursorPosition - visibleTextLength |
904 | end |
905 | |
906 | if availableTextWidth and not self.areBackDotsVisible and self.firstVisibleCharacterPosition > 1 then |
907 | -- check if there is still room for additonal characters (can happen if text gets deleted) |
908 | local lastCharacterPosition = visibleTextLength + self.firstVisibleCharacterPosition |
909 | local nextCharacter = utf8Substr(displayText, self.firstVisibleCharacterPosition - 1, 1) |
910 | local additionalCharacterWidth = getTextWidth(self.textSize, nextCharacter) |
911 | if visibleTextWidth + additionalCharacterWidth <= availableTextWidth and self.firstVisibleCharacterPosition > 1 then |
912 | while visibleTextWidth + additionalCharacterWidth <= availableTextWidth and self.firstVisibleCharacterPosition > 1 do |
913 | -- there is still room for additonal characters |
914 | self.firstVisibleCharacterPosition = self.firstVisibleCharacterPosition - 1 |
915 | visibleTextWidth = visibleTextWidth + additionalCharacterWidth |
916 | nextCharacter = utf8Substr(displayText, self.firstVisibleCharacterPosition - 1, 1) |
917 | additionalCharacterWidth = getTextWidth(self.textSize, nextCharacter) |
918 | end |
919 | |
920 | if self.firstVisibleCharacterPosition > 1 then |
921 | self.areFrontDotsVisible = false |
922 | local availableWidthWithoutFrontDots = self:getAvailableTextWidth() |
923 | self.areFrontDotsVisible = true |
924 | local neededWidthForCompleteText = getTextWidth(self.textSize, displayText) |
925 | if neededWidthForCompleteText <= availableWidthWithoutFrontDots then |
926 | self.areFrontDotsVisible = false |
927 | self.firstVisibleCharacterPosition = 1 |
928 | end |
929 | else |
930 | -- all characters are visible |
931 | self.areFrontDotsVisible = false |
932 | end |
933 | |
934 | visibleText = utf8Substr(displayText, self.firstVisibleCharacterPosition - 1, lastCharacterPosition) |
935 | end |
936 | end |
937 | |
938 | |
939 | self.isVisibleTextPart1Visible = true |
940 | self.visibleTextPart1 = utf8Substr(visibleText, 0, self.cursorPosition - self.firstVisibleCharacterPosition) |
941 | if visibleTextLength > self.cursorPosition - self.firstVisibleCharacterPosition then |
942 | self.isVisibleTextPart2Visible = true |
943 | self.visibleTextPart2 = utf8Substr(visibleText, self.cursorPosition - self.firstVisibleCharacterPosition) |
944 | end |
945 | |
946 | else |
947 | -- input is not gathered, cursor is not shown, |
948 | -- text is displayed from its beginning, only back additonal text marker may be displayed if text is too long |
949 | local textWidth = getTextWidth(self.textSize, displayText) |
950 | -- check if additional text marker has to be displayed |
951 | if availableTextWidth and textWidth > availableTextWidth then |
952 | --self.isBackAdditionalTextMarkerVisible = true |
953 | self.areBackDotsVisible = true |
954 | availableTextWidth = self:getAvailableTextWidth() |
955 | end |
956 | |
957 | -- set visible text |
958 | if availableTextWidth and textWidth > availableTextWidth then |
959 | -- not all text fits into the visible area |
960 | self.visibleTextPart1 = TextInputElement.limitTextToAvailableWidth(displayText, self.textSize, availableTextWidth) |
961 | self.isVisibleTextPart1Visible = true |
962 | else |
963 | -- all text fits into the visible area |
964 | self.visibleTextPart1 = displayText |
965 | self.isVisibleTextPart1Visible = true |
966 | end |
967 | end |
968 | setTextBold(false) |
969 | |
970 | -- print(string.format("updateVisibleTextElements finished :")) |
971 | -- print(string.format( |
972 | -- "text: %s - cursorPosition: %d - firstVisibleCharacterPosition: %d - areFrontDotsVisible: %s - isVisibleTextPart1Visible: %s - visibleTextPart1: %s - isCursorVisible: %s - isVisibleTextPart2Visible: %s - visibleTextPart2: %s - areBackDotsVisible: %s", |
973 | -- self.text, self.cursorPosition, self.firstVisibleCharacterPosition, tostring(self.areFrontDotsVisible), tostring(self.isVisibleTextPart1Visible), self.visibleTextPart1, tostring(self.isCursorVisible), tostring(self.isVisibleTextPart2Visible), self.visibleTextPart2, tostring(self.areBackDotsVisible))) |
974 | end |