1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 18:50:54 +00:00

Merge pull request #507 from lightest/CU-2da76e8_incorrect_size_on_rebuild

Incorrect behavior on textbox refresh when size attribute becomes negative
This commit is contained in:
Alain Pitiot 2022-06-23 09:13:20 +02:00 committed by GitHub
commit 4937ab5308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -477,9 +477,12 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
{
this._pixi.on("input", (textContent) => {
this._text = textContent;
let size = [this._pixi.width, this._pixi.height];
size = util.to_unit(size, "pix", this._win, this._units);
this._setAttribute("size", size, false);
if (this._fitToContent)
{
// make sure that size attribute is updated when fitToContent = true
const size = util.to_unit([this._pixi.width, this._pixi.height], "pix", this._win, this._units);
this._setAttribute("size", size, false);
}
});
}
@ -517,8 +520,8 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
const letterHeight_px = Math.round(this._getLengthPix(this._letterHeight));
const padding_px = Math.round(this._getLengthPix(this._padding));
const borderWidth_px = Math.round(this._getLengthPix(this._borderWidth));
const width_px = Math.round(this._getLengthPix(this._size[0]));
const height_px = Math.round(this._getLengthPix(this._size[1]));
const width_px = Math.abs(Math.round(this._getLengthPix(this._size[0])));
const height_px = Math.abs(Math.round(this._getLengthPix(this._size[1])));
return {
// input style properties eventually become CSS, so same syntax applies