mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Change logic compare block to eject mismatched blocks.
This commit is contained in:
@@ -312,15 +312,18 @@ Blockly.Blocks['logic_compare'] = {
|
||||
}
|
||||
var blockA = this.getInputTargetBlock('A');
|
||||
var blockB = this.getInputTargetBlock('B');
|
||||
if (blockA) {
|
||||
this.getInput('B').setCheck(blockA.outputConnection.check_);
|
||||
}
|
||||
if (blockB) {
|
||||
this.getInput('A').setCheck(blockB.outputConnection.check_);
|
||||
}
|
||||
if (!blockA && !blockB) {
|
||||
this.getInput('A').setCheck(null);
|
||||
this.getInput('B').setCheck(null);
|
||||
// Keep track of which block was added second
|
||||
// (so the first block may be ejected upon mismatch).
|
||||
if (blockA && !blockB) {
|
||||
this.blockAPriority_ = false;
|
||||
} else if (!blockA && blockB) {
|
||||
this.blockAPriority_ = true;
|
||||
} else if (blockA && blockB &&
|
||||
!blockA.outputConnection.checkType_(blockB.outputConnection)) {
|
||||
// Mismatch between two inputs. Disconnect one and bump it away.
|
||||
var child = this.blockAPriority_ ? blockB : blockA;
|
||||
child.setParent(null);
|
||||
child.bumpNeighbours_();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user