Update the style on blocks in the mutator

This commit is contained in:
alschmiedt
2018-12-21 09:00:55 -08:00
parent 1b3955d9d6
commit d3a603ffd9
2 changed files with 25 additions and 1 deletions

View File

@@ -693,7 +693,12 @@ Blockly.setStyle = function(style) {
workspace.refreshToolboxSelection();
for (var i = 0; i < blocks.length; i++) {
var block = blocks[i];
block.setStyle(block.getStyleName());
var blockStyleName = block.getStyleName();
block.setStyle(blockStyleName);
if (block.mutator) {
block.mutator.updateBlockStyle(blockStyleName);
}
}
var event = new Blockly.Events.Ui(null, 'styleChanged');

View File

@@ -397,6 +397,25 @@ Blockly.Mutator.prototype.dispose = function() {
Blockly.Icon.prototype.dispose.call(this);
};
/**
* Update the styles on all blocks in the mutator.
* @public
*/
Blockly.Mutator.prototype.updateBlockStyle = function() {
if (this.workspace_ && this.workspace_.getAllBlocks()){
var workspaceBlocks = this.workspace_.getAllBlocks();
for (var i = 0; i < workspaceBlocks.length; i++) {
var block = workspaceBlocks[i];
block.setStyle(block.getStyleName());
}
var flyoutBlocks = this.workspace_.flyout_.workspace_.getAllBlocks();
for (var i = 0; i < flyoutBlocks.length; i++) {
var block = flyoutBlocks[i];
block.setStyle(block.getStyleName());
}
}
};
/**
* Reconnect an block to a mutated input.
* @param {Blockly.Connection} connectionChild Connection on child block.