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

textBox#setAlignment method added to avoid complete reconstruction when changing text alignment

This commit is contained in:
lgtst 2022-03-30 23:56:54 +03:00
parent 08b71731d1
commit d0ed55758b

View File

@ -144,8 +144,7 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
this._addAttribute( this._addAttribute(
"alignment", "alignment",
alignment, alignment,
"left", "left"
this._onChange(true, true),
); );
// colors: // colors:
@ -228,6 +227,21 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
this.setText(); this.setText();
} }
/**
* Setter for the alignment attribute.
*
* @name module:visual.TextBox#setAlignment
* @public
* @param {boolean} alignment - alignment of the text
* @param {boolean} [log= false] - whether of not to log
*/
setAlignment(alignment = "left", log = false) {
this._setAttribute("alignment", alignment, log);
if (this._pixi !== undefined) {
this._pixi.setInputStyle("text-align", alignment);
}
}
/** /**
* For tweaking the underlying input value. * For tweaking the underlying input value.
* *