瀏覽代碼

Correct DEL overrun

Guide 6 年之前
父節點
當前提交
a02e688976
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      gui/src/2D/controls/inputText.ts

+ 1 - 1
gui/src/2D/controls/inputText.ts

@@ -307,7 +307,7 @@ export class InputText extends Control implements IFocusableControl {
                 }
                 return;
             case 46: // DELETE
-                if (this._text && this._text.length > 0) {
+                if (this._text && this._text.length > 0  && this._cursorOffset > 0) {
                     let deletePosition = this._text.length - this._cursorOffset;
                     this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
                     this._cursorOffset--;