mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Disable break/return blocks in addition to warning.
This commit is contained in:
parent
0537f4829e
commit
122f69f92c
2 changed files with 18 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue