From 122f69f92c440d01b88aabe106cf34ae67071fcf Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 19 Oct 2016 17:04:03 -0700 Subject: [PATCH] Disable break/return blocks in addition to warning. --- blocks/loops.js | 9 +++++++++ blocks/procedures.js | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/blocks/loops.js b/blocks/loops.js index b9bae1e80..3d72d5b56 100644 --- a/blocks/loops.js +++ b/blocks/loops.js @@ -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); + } } }, /** diff --git a/blocks/procedures.js b/blocks/procedures.js index 3ada788cf..25661c217 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -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); + } } }, /**