Disable break/return blocks in addition to warning.

This commit is contained in:
Neil Fraser 2016-10-19 17:04:03 -07:00
parent 0537f4829e
commit 122f69f92c
2 changed files with 18 additions and 0 deletions

View file

@ -257,6 +257,9 @@ Blockly.Blocks['controls_flow_statements'] = {
* @this Blockly.Block
*/
onchange: function(e) {
if (this.workspace.isDragging()) {
return; // Don't change state at the start of a drag.
}
var legal = false;
// Is the block nested in a loop?
var block = this;
@ -269,8 +272,14 @@ Blockly.Blocks['controls_flow_statements'] = {
} while (block);
if (legal) {
this.setWarningText(null);
if (!this.isInFlyout) {
this.setDisabled(false);
}
} else {
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
if (!this.isInFlyout && !this.getInheritedDisabled()) {
this.setDisabled(true);
}
}
},
/**

View file

@ -843,6 +843,9 @@ Blockly.Blocks['procedures_ifreturn'] = {
* @this Blockly.Block
*/
onchange: function(e) {
if (this.workspace.isDragging()) {
return; // Don't change state at the start of a drag.
}
var legal = false;
// Is the block nested in a procedure?
var block = this;
@ -868,8 +871,14 @@ Blockly.Blocks['procedures_ifreturn'] = {
this.hasReturnValue_ = true;
}
this.setWarningText(null);
if (!this.isInFlyout) {
this.setDisabled(false);
}
} else {
this.setWarningText(Blockly.Msg.PROCEDURES_IFRETURN_WARNING);
if (!this.isInFlyout && !this.getInheritedDisabled()) {
this.setDisabled(true);
}
}
},
/**