mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
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:
@@ -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_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user