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

Merge pull request #164 from thewhodidthis/bf#159+160--textbox

visual/TextBox: Add methods for accessing the underlying input text
This commit is contained in:
Alain Pitiot 2020-10-27 10:51:43 +01:00 committed by GitHub
commit 413f6d60a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -165,6 +165,53 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
}
/**
* Clears the current text value.
*
* @name module:visual.TextBox#reset
* @public
*/
reset()
{
this.setText();
}
/**
* For tweaking the underlying input value.
*
* @name module:visual.TextBox#setText
* @public
* @param {string} text
*/
setText(text = '')
{
if (typeof this._pixi !== 'undefined')
{
this._pixi.text = text;
}
this._text = text;
}
/**
* For accessing the underlying input value.
*
* @name module:visual.TextBox#getText
* @public
* @return {string} - the current text value of the underlying input element.
*/
getText()
{
if (typeof this._pixi !== 'undefined')
{
return this._pixi.text;
}
return this._text;
}
/**
* Setter for the size attribute.