Fix FieldTextInput lack of Change event

FieldTextInput was not triggering a Change event and this prevented an
onWorkspaceChanged event from firing in the BlocklyPanel. This commit
separates the semantics of the text and value getter/setters so that
updates to the text in onHtmlInputChange handler do not prevent an
event being triggered in setValue() after the user commits the change.
This commit is contained in:
Evan W. Patton
2017-05-23 10:34:42 -04:00
parent 35881a7a98
commit 20001aa473

View File

@@ -66,6 +66,13 @@ Blockly.FieldTextInput.prototype.CURSOR = 'text';
*/
Blockly.FieldTextInput.prototype.spellcheck_ = true;
/**
* The value of the field.
* @type {?string}
* @private
*/
Blockly.FieldTextInput.prototype.value_ = null;
/**
* Close the input widget if this input is being deleted.
*/
@@ -92,6 +99,18 @@ Blockly.FieldTextInput.prototype.setValue = function(newValue) {
}
}
Blockly.Field.prototype.setValue.call(this, newValue);
if (newValue !== null) {
this.value_ = newValue;
}
};
/**
* Get the value of this field.
* @returns {?string}
* @override
*/
Blockly.FieldTextInput.prototype.getValue = function() {
return this.value_;
};
/**