Skip to content

Commit

Permalink
Merge pull request #13404 from carolhmj/GUIFixTextHeightInputTextArea
Browse files Browse the repository at this point in the history
Fix calculation of text height in InputTextArea
  • Loading branch information
sebavan authored Jan 4, 2023
2 parents 477d7d6 + e3db9b5 commit cb27184
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
23 changes: 12 additions & 11 deletions packages/dev/gui/src/2D/controls/inputTextArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,17 +663,9 @@ export class InputTextArea extends InputText {
}
}

/**
* Processing of child after the parent measurement update
*
* @param parentMeasure The parent measure
* @param context The rendering canvas
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected _additionalProcessing(parentMeasure: Measure, context: ICanvasRenderingContext): void {
this._clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, parentMeasure.width);
this._clipTextTop = this._currentMeasure.top + this._margin.getValueInPixel(this._host, parentMeasure.height);
private _computeScroll() {
this._clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
this._clipTextTop = this._currentMeasure.top + this._margin.getValueInPixel(this._host, this._cachedParentMeasure.height);

if (this._isFocused && this._lines[this._cursorInfo.currentLineIndex].width > this._availableWidth) {
const textLeft = this._clipTextLeft - this._lines[this._cursorInfo.currentLineIndex].width + this._availableWidth;
Expand All @@ -695,7 +687,14 @@ export class InputTextArea extends InputText {
} else {
this._scrollTop = this._clipTextTop;
}
}

/**
* Processing of child after the parent measurement update
*
* @internal
*/
protected _additionalProcessing(): void {
// Flush the highlighted text each frame
this.highlightedText = "";

Expand Down Expand Up @@ -795,6 +794,8 @@ export class InputTextArea extends InputText {
}

public _draw(context: ICanvasRenderingContext): void {
this._computeScroll();

this._scrollLeft = this._scrollLeft ?? 0;
this._scrollTop = this._scrollTop ?? 0;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/tools/tests/test/visualization/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,10 @@
"playgroundId": "#20OAV9#9228",
"referenceImage": "exportGltfKHRTextureTransform.png",
"renderCount": 5
},
{
"title": "GUI Input Text Area Inside ScrollViewer",
"playgroundId": "#NVAEWD#69"
}
]
}

0 comments on commit cb27184

Please sign in to comment.