Skip to content

Commit 88b8a8c

Browse files
committed
fix checkboxes (blocks part)
not custom block ghost blocks though
1 parent 83520b3 commit 88b8a8c

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

core/block.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,14 @@ Blockly.Block.prototype.isShadow = function() {
654654

655655
/**
656656
* Set whether this block is a shadow block or not.
657-
* @param {boolean} shadow True if a shadow.
657+
* @param {boolean} newBoolean True if a shadow.
658658
*/
659-
Blockly.Block.prototype.setShadow = function(shadow) {
660-
this.isShadow_ = shadow;
659+
Blockly.Block.prototype.setShadow = function(newBoolean) {
660+
if (this.isShadow_ != newBoolean) {
661+
Blockly.Events.fire(new Blockly.Events.BlockChange(
662+
this, 'shadow', null, this.isShadow_, newBoolean));
663+
this.isShadow_ = newBoolean;
664+
}
661665
};
662666

663667
/**

core/block_events.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ Blockly.Events.Change.prototype.run = function(forward) {
191191
case 'inline':
192192
block.setInputsInline(value);
193193
break;
194+
case 'shadow':
195+
block.setShadow(value);
196+
break;
194197
case 'mutation':
195198
var oldMutation = '';
196199
if (block.mutationToDom) {

core/block_svg.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,11 @@ Blockly.BlockSvg.prototype.setEditable = function(editable) {
825825
Blockly.BlockSvg.prototype.setShadow = function(shadow) {
826826
Blockly.BlockSvg.superClass_.setShadow.call(this, shadow);
827827
this.updateColour();
828+
829+
if (this.rendered) {
830+
this.render();
831+
this.bumpNeighbours_();
832+
}
828833
};
829834

830835
/**

core/field_checkbox.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ Blockly.FieldCheckbox.prototype.showEditor_ = function() {
172172
}
173173
// Remove the shadow dom from the connection. (to prevent regeneration)
174174
input.connection.setShadowDom();
175+
// Un-shadow the block so the VM will properly delete it.
176+
source.setShadow(false);
175177
// Dispose of our shadow parent.
176178
source.unplug(false);
177179
source.dispose(false, false);

0 commit comments

Comments
 (0)