Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calculation of text height in InputTextArea #13404

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
]
}