Fix checkbox events. Fix block deletion while mutator is open.

This commit is contained in:
Neil Fraser
2016-03-14 23:14:58 -07:00
parent 72bb08a4ec
commit 95fbc0bb49
2 changed files with 5 additions and 1 deletions

View File

@@ -941,13 +941,13 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) {
// Stop rerendering.
this.rendered = false;
Blockly.BlockSvg.superClass_.dispose.call(this, healStack);
Blockly.Events.disable();
var icons = this.getIcons();
for (var i = 0; i < icons.length; i++) {
icons[i].dispose();
}
Blockly.Events.enable();
Blockly.BlockSvg.superClass_.dispose.call(this, healStack);
goog.dom.removeNode(this.svgGroup_);
// Sever JavaScript to DOM connections.

View File

@@ -85,6 +85,10 @@ Blockly.FieldCheckbox.prototype.getValue = function() {
Blockly.FieldCheckbox.prototype.setValue = function(strBool) {
var newState = (strBool == 'TRUE');
if (this.state_ !== newState) {
if (this.sourceBlock_ && Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.Change(
this.sourceBlock_, 'field', this.name, this.state_, newState));
}
this.state_ = newState;
if (this.checkElement_) {
this.checkElement_.style.display = newState ? 'block' : 'none';