Break out procedure call argument rendering into separate function.

This commit is contained in:
Neil Fraser
2015-04-30 14:57:14 -07:00
parent 3ff69d47fe
commit f454f77910
3 changed files with 31 additions and 18 deletions

View File

@@ -526,13 +526,12 @@ Blockly.Blocks['procedures_callnoreturn'] = {
}
// Rebuild the block's arguments.
this.arguments_ = [].concat(paramNames);
this.renderArgs_();
this.quarkArguments_ = paramIds;
for (var i = 0; i < this.arguments_.length; i++) {
var input = this.appendValueInput('ARG' + i)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(this.arguments_[i]);
if (this.quarkArguments_) {
// Reconnect any child blocks.
// Reconnect any child blocks.
if (this.quarkArguments_) {
for (var i = 0; i < this.arguments_.length; i++) {
var input = this.getInput('ARG' + i);
var quarkName = this.quarkArguments_[i];
if (quarkName in this.quarkConnections_) {
var connection = this.quarkConnections_[quarkName];
@@ -545,6 +544,23 @@ Blockly.Blocks['procedures_callnoreturn'] = {
}
}
}
}
// Restore rendering and show the changes.
this.rendered = savedRendered;
if (this.rendered) {
this.render();
}
},
/**
* Render the arguments.
* @this Blockly.Block
* @private
*/
renderArgs_: function() {
for (var i = 0; i < this.arguments_.length; i++) {
var input = this.appendValueInput('ARG' + i)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(this.arguments_[i]);
input.init();
}
// Add 'with:' if there are parameters.
@@ -561,11 +577,6 @@ Blockly.Blocks['procedures_callnoreturn'] = {
}
}
}
// Restore rendering and show the changes.
this.rendered = savedRendered;
if (this.rendered) {
this.render();
}
},
/**
* Create XML to represent the (non-editable) name and arguments.
@@ -663,6 +674,7 @@ Blockly.Blocks['procedures_callreturn'] = {
renameProcedure: Blockly.Blocks['procedures_callnoreturn'].renameProcedure,
setProcedureParameters:
Blockly.Blocks['procedures_callnoreturn'].setProcedureParameters,
renderArgs_: Blockly.Blocks['procedures_callnoreturn'].renderArgs_,
mutationToDom: Blockly.Blocks['procedures_callnoreturn'].mutationToDom,
domToMutation: Blockly.Blocks['procedures_callnoreturn'].domToMutation,
renameVar: Blockly.Blocks['procedures_callnoreturn'].renameVar,