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

_getTextInputOptions() now takes into account possibility of negative size; size attr update on input only happens when fitToContent=true;

This commit is contained in:
lgtst 2022-06-16 17:37:26 +03:00
parent 88e7d127b3
commit b8bff3ca91

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