mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
Deprecated field setText function.
This commit is contained in:
@@ -1078,7 +1078,7 @@ Blockly.Block.prototype.updateVarName = function(variable) {
|
||||
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
||||
if (field.referencesVariables() &&
|
||||
variable.getId() == field.getValue()) {
|
||||
field.setText(variable.name);
|
||||
field.updateVariableName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,6 +706,7 @@ Blockly.Field.prototype.getText = function() {
|
||||
/**
|
||||
* Set the text in this field. Trigger a rerender of the source block.
|
||||
* @param {*} newText New text.
|
||||
* @deprecated 2019 setText should not be used directly. Use setValue instead.
|
||||
*/
|
||||
Blockly.Field.prototype.setText = function(newText) {
|
||||
if (newText === null) {
|
||||
|
||||
@@ -167,8 +167,19 @@ Blockly.FieldImage.prototype.getFlipRtl = function() {
|
||||
* Set the alt text of this image.
|
||||
* @param {?string} alt New alt text.
|
||||
* @override
|
||||
* @deprecated 2019 setText has been deprecated for all fields. Instead use
|
||||
* setAlt to set the alt text of the field.
|
||||
*/
|
||||
Blockly.FieldImage.prototype.setText = function(alt) {
|
||||
this.setAlt(alt);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the alt text of this image.
|
||||
* @param {?string} alt New alt text.
|
||||
* @public
|
||||
*/
|
||||
Blockly.FieldImage.prototype.setAlt = function(alt) {
|
||||
if (alt === null) {
|
||||
// No change if null.
|
||||
return;
|
||||
|
||||
@@ -253,7 +253,7 @@ Blockly.FieldVariable.prototype.doClassValidation_ = function(newId) {
|
||||
Blockly.FieldVariable.prototype.doValueUpdate_ = function(newId) {
|
||||
this.variable_ = Blockly.Variables.getVariable(this.workspace_, newId);
|
||||
this.value_ = newId;
|
||||
this.text_ = (this.variable_.name);
|
||||
this.text_ = this.variable_.name;
|
||||
this.isDirty_ = true;
|
||||
};
|
||||
|
||||
@@ -341,6 +341,16 @@ Blockly.FieldVariable.prototype.setTypes_ = function(opt_variableTypes,
|
||||
this.variableTypes = variableTypes;
|
||||
};
|
||||
|
||||
/**
|
||||
* A callback to update the name of a variable. Should only be called by
|
||||
* the block.
|
||||
* @package
|
||||
*/
|
||||
Blockly.FieldVariable.prototype.updateVariableName = function() {
|
||||
this.text_ = this.variable_.name;
|
||||
this.forceRerender();
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a sorted list of variable names for variable dropdown menus.
|
||||
* Include a special option at the end for creating a new variable name.
|
||||
|
||||
Reference in New Issue
Block a user