1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-13 17:12:55 +00:00

Merge pull request #340 from tpronk/textbox_stay_on_resize

BF: Retain entered text (and placeholder) upon resize
This commit is contained in:
Alain Pitiot 2021-05-31 12:46:19 +02:00 committed by GitHub
commit 04b21a4274

View File

@ -60,6 +60,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,
@ -405,6 +411,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
@ -426,7 +435,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
{ {