Parameter block is removed from init prototype of fields and its usage
is replaced by this.sourceBlock_
This commit is contained in:
miguel76 2016-04-09 12:01:38 -03:00
parent 78b4514f15
commit 1e3297ba0a
4 changed files with 12 additions and 14 deletions

View file

@ -79,18 +79,19 @@ Blockly.FieldVariable.prototype.setValidator = function(handler) {
/**
* Install this dropdown on a block.
* @param {!Blockly.Block} block The block containing this text.
*/
Blockly.FieldVariable.prototype.init = function(block) {
Blockly.FieldVariable.prototype.init = function() {
if (this.fieldGroup_) {
// Dropdown has already been initialized once.
return;
}
Blockly.FieldVariable.superClass_.init.call(this, block);
Blockly.FieldVariable.superClass_.init.call(this);
if (!this.getValue()) {
// Variables without names get uniquely named for this workspace.
var workspace =
block.isInFlyout ? block.workspace.targetWorkspace : block.workspace;
this.sourceBlock_.isInFlyout ?
this.sourceBlock_.workspace.targetWorkspace :
this.sourceBlock_.workspace;
this.setValue(Blockly.Variables.generateUniqueName(workspace));
}
};