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

Retain entered text (and placeholder) upon resize

This commit is contained in:
Thomas Pronk 2021-05-17 23:10:47 +01:00
parent 733526ae63
commit de2b210e99

View File

@ -59,6 +59,12 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
'', '',
this._onChange(true, true) this._onChange(true, true)
); );
this._addAttribute(
'placeholder',
text,
'',
this._onChange(true, true)
);
this._addAttribute( this._addAttribute(
'anchor', 'anchor',
anchor, anchor,
@ -404,6 +410,9 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
{ {
this._pixi.destroy(true); this._pixi.destroy(true);
} }
// Get the currently entered text
let enteredText = this._pixi !== undefined? this._pixi.text: '';
// Create new TextInput
this._pixi = new TextInput(this._getTextInputOptions()); this._pixi = new TextInput(this._getTextInputOptions());
// listeners required for regular textboxes, but may cause problems with button stimuli // listeners required for regular textboxes, but may cause problems with button stimuli
@ -425,7 +434,8 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
} }
if (this._editable) if (this._editable)
{ {
this._pixi.placeholder = this._text; this.text = enteredText;
this._pixi.placeholder = this._placeholder;
} }
else else
{ {