From 67c606d4b22f48444e1661999c06fd350f1e2315 Mon Sep 17 00:00:00 2001 From: Sotiri Bakagiannis Date: Fri, 4 Sep 2020 12:03:57 +0100 Subject: [PATCH] visual/TextBox: add methods for accessing and resetting the underlying input value --- js/visual/TextBox.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/js/visual/TextBox.js b/js/visual/TextBox.js index 5721803..24b254c 100644 --- a/js/visual/TextBox.js +++ b/js/visual/TextBox.js @@ -165,6 +165,49 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin) } + /** + * Clears the current text value. + * + * @name module:visual.TextBox#reset + * @public + */ + reset() + { + this.setInputText(); + } + + + /** + * For tweaking the underlying input value. + * + * @name module:visual.TextBox#setInputText + * @public + * @param {string} text + */ + setInputText(text = '') + { + if (typeof this._pixi !== 'undefined') + { + this._pixi.text = text; + } + } + + + /** + * For accessing the underlying input value. + * + * @name module:visual.TextBox#getInputText + * @public + * @return {string} - the current text value of the underlying input element. + */ + getInputText() + { + if (typeof this._pixi !== 'undefined') + { + return this._pixi.text; + } + } + /** * Setter for the size attribute.