Now that text input's setText skips setValue, it needs to explicitly create a change event

This commit is contained in:
Rachel Fenichel
2017-01-03 14:51:28 -08:00
parent 20cf6abb5f
commit 056824593e

View File

@@ -94,6 +94,18 @@ Blockly.FieldTextInput.prototype.setValue = function(newValue) {
Blockly.Field.prototype.setValue.call(this, newValue);
};
/**
* Set the text in this field and fire a change event.
* @param {*} newText New text.
*/
Blockly.FieldTextInput.prototype.setText = function(newText) {
if (this.sourceBlock_ && Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.Change(
this.sourceBlock_, 'field', this.name, this.text_, newText));
}
Blockly.Field.prototype.setText.call(this, newText);
};
/**
* Set whether this field is spellchecked by the browser.
* @param {boolean} check True if checked.