Commit 145e718b authored by Evan W. Patton's avatar Evan W. Patton

Fix vertical parameter orientation on procedure blocks

Procedure definitions have the option for horizontal/vertical
orientation of parameters. However, switching resulted in the inputs
disappearing from the block. This was caused by the new fields not
being initialized correctly such that when the block attempted to
redraw, expected SVG elements were undefined.

This commit fixes the updateParams_ method for procedure blocks so
that they will correctly handle switching between the two cases.

Change-Id: Ib9a161548954a2990a0351ad07a808c35d2bc928
parent a5fa4f6f
......@@ -136,8 +136,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
function() {thisBlock.removeInput('HEADER');}
);
// [lyn, 07/02/14 fixed logic] remove all old argument inputs (if they were vertical)
if (! this.horizontalParameters) {
// Remove all existing vertical inputs (we will create new ones if necessary)
var oldArgCount = this.inputList.length - 1; // Only args and body are left
if (oldArgCount > 0) {
var paramInput0 = this.getInput('VAR0');
......@@ -158,7 +157,6 @@ Blockly.Blocks['procedures_defnoreturn'] = {
}
}
}
}
//empty the inputList then recreate it
this.inputList = [];
......@@ -171,14 +169,15 @@ Blockly.Blocks['procedures_defnoreturn'] = {
//add an input title for each argument
//name each input after the block and where it appears in the block to reference it later
for (var i = 0; i < this.arguments_.length; i++) {
if (this.horizontalParameters) { // horizontal case
for (var i = 0; i < this.arguments_.length; i++) {
headerInput.appendField(' ')
.appendField(this.parameterFlydown(i), // [lyn, 10/10/13] Changed to param flydown
'VAR' + i); // Tag with param tag to make it easy to find later.
}
} else { // vertical case
for (var i = 0; i < this.arguments_.length; i++) {
this.appendDummyInput('VAR' + i)
// .appendField(this.arguments_[i])
.appendField(this.parameterFlydown(i), 'VAR' + i)
.setAlign(Blockly.ALIGN_RIGHT);
}
......@@ -192,8 +191,16 @@ Blockly.Blocks['procedures_defnoreturn'] = {
// Without it, get bug noticed by Andrew in which toggling horizontal -> vertical params
// in procedure decl doesn't handle body tag appropriately!
if (this.rendered) {
for (var i = 0; i < this.inputList.length; i++) {
this.inputList[i].init();
}
this.render();
}
if (Blockly.Events.isEnabled()) {
// Trigger a Blockly UI change event
Blockly.Events.fire(new Blockly.Events.Ui(this, 'parameter_orientation',
(!this.horizontalParameters).toString(), this.horizontalParameters.toString()))
}
// console.log("exit procedures_defnoreturn updateParams_()");
},
// [lyn, 10/26/13] Introduced this to correctly handle renaming of [(1) caller arg labels and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment