ssaket 6 rokov pred
rodič
commit
dbf4ee3731
1 zmenil súbory, kde vykonal 11 pridanie a 4 odobranie
  1. 11 4
      gui/src/2D/controls/inputText.ts

+ 11 - 4
gui/src/2D/controls/inputText.ts

@@ -548,9 +548,16 @@ export class InputText extends Control implements IFocusableControl {
                 if (this._cursorOffset === 0) {
                     this.text += key;
                 } else {
-                    let insertPosition = this._text.length - this._cursorOffset;
-
-                    this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
+                    if (this._isTextHighlightOn) {
+                        this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
+                        this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
+                        this._isTextHighlightOn = false;
+                        this._blinkIsEven = false;
+                    }
+                    else {
+                        let insertPosition = this._text.length - this._cursorOffset;
+                        this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
+                    }
                 }
             }
         }
@@ -577,7 +584,7 @@ export class InputText extends Control implements IFocusableControl {
 
         this._startHighlightIndex = 0;
         this._endHighlightIndex = this._text.length;
-        this._cursorOffset = 0;
+        this._cursorOffset = this._text.length;
         this._markAsDirty();
     }