瀏覽代碼

Fix inputText clipping issues

David Catuhe 6 年之前
父節點
當前提交
7596cba2f4

+ 6 - 3
gui/src/2D/controls/inputText.ts

@@ -696,7 +696,7 @@ export class InputText extends Control implements IFocusableControl {
         let rWord = /\w+/g, moveLeft, moveRight;
         do {
             moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
-            moveLeft =  this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1 ].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
+            moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
         } while (moveLeft || moveRight);
 
         this._cursorOffset = this.text.length - this._startHighlightIndex;
@@ -828,7 +828,10 @@ export class InputText extends Control implements IFocusableControl {
 
         let rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
         let availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
-        context.save();
+
+        if (this._isFocused) {
+            context.save();
+        }
         context.beginPath();
         context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
         context.clip();
@@ -906,7 +909,7 @@ export class InputText extends Control implements IFocusableControl {
                 this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
                 let width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
                 if (highlightCursorLeft < clipTextLeft) {
-                    width =  width - (clipTextLeft - highlightCursorLeft);
+                    width = width - (clipTextLeft - highlightCursorLeft);
                     if (!width) {
                         // when using left arrow on text.length > availableWidth;
                         // assigns the width of the first letter after clipTextLeft

+ 2 - 2
inspector/src/components/actionTabs/tabs/propertyGrids/gui/gridPropertyGridComponent.tsx

@@ -29,7 +29,7 @@ export class GridPropertyGridComponent extends React.Component<IGridPropertyGrid
         return (
             rows.map((rd, i) => {
                 return (
-                    <TextLineComponent key={`r${i}`} label={`Row #${i}`} value={rd.toString(grid.host)} underline={i === grid.rowCount - 1} />
+                    <TextLineComponent key={`r${i}`} label={`Row ${i}`} value={rd.toString(grid.host)} underline={i === grid.rowCount - 1} />
                 )
             })
         );
@@ -46,7 +46,7 @@ export class GridPropertyGridComponent extends React.Component<IGridPropertyGrid
         return (
             cols.map((cd, i) => {
                 return (
-                    <TextLineComponent key={`c${i}`} label={`Column #${i}`} value={cd.toString(grid.host)} />
+                    <TextLineComponent key={`c${i}`} label={`Column ${i}`} value={cd.toString(grid.host)} />
                 )
             })
         );