mirror of
https://github.com/google/blockly.git
synced 2026-01-11 19:07:08 +01:00
Bug fix for clear (#582)
This commit is contained in:
committed by
picklesrus
parent
b0432306a1
commit
aa9dd9646a
@@ -399,48 +399,35 @@ WorkspaceFactoryController.prototype.updatePreview = function() {
|
||||
// through event handlers.
|
||||
Blockly.Events.disable();
|
||||
|
||||
if (this.selectedMode == WorkspaceFactoryController.MODE_TOOLBOX) {
|
||||
// If currently editing the toolbox.
|
||||
|
||||
// Only update the toolbox if not in read only mode.
|
||||
if (!this.model.options['readOnly']) {
|
||||
// Get toolbox XML.
|
||||
var tree = Blockly.Options.parseToolboxTree
|
||||
(this.generator.generateToolboxXml());
|
||||
// Only update the toolbox if not in read only mode.
|
||||
if (!this.model.options['readOnly']) {
|
||||
// Get toolbox XML.
|
||||
var tree = Blockly.Options.parseToolboxTree
|
||||
(this.generator.generateToolboxXml());
|
||||
|
||||
// No categories, creates a simple flyout.
|
||||
if (tree.getElementsByTagName('category').length == 0) {
|
||||
// No categories, creates a simple flyout.
|
||||
if (tree.getElementsByTagName('category').length == 0) {
|
||||
// No categories, creates a simple flyout.
|
||||
if (this.previewWorkspace.toolbox_) {
|
||||
this.reinjectPreview(tree); // Switch to simple flyout, expensive.
|
||||
} else {
|
||||
this.previewWorkspace.updateToolbox(tree);
|
||||
}
|
||||
if (this.previewWorkspace.toolbox_) {
|
||||
this.reinjectPreview(tree); // Switch to simple flyout, expensive.
|
||||
} else {
|
||||
// Uses categories, creates a toolbox.
|
||||
if (!this.previewWorkspace.toolbox_) {
|
||||
this.reinjectPreview(tree); // Create a toolbox, expensive.
|
||||
} else {
|
||||
this.previewWorkspace.updateToolbox(tree);
|
||||
}
|
||||
this.previewWorkspace.updateToolbox(tree);
|
||||
}
|
||||
} else {
|
||||
// Uses categories, creates a toolbox.
|
||||
if (!this.previewWorkspace.toolbox_) {
|
||||
this.reinjectPreview(tree); // Create a toolbox, expensive.
|
||||
} else {
|
||||
this.previewWorkspace.updateToolbox(tree);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update pre-loaded blocks in the preview workspace to make sure that
|
||||
// blocks don't get cleared when updating preview from event listeners while
|
||||
// switching modes.
|
||||
this.previewWorkspace.clear();
|
||||
Blockly.Xml.domToWorkspace(this.generator.generateWorkspaceXml(),
|
||||
this.previewWorkspace);
|
||||
|
||||
} else if (this.selectedMode == WorkspaceFactoryController.MODE_PRELOAD){
|
||||
// If currently editing the pre-loaded workspace.
|
||||
this.previewWorkspace.clear();
|
||||
Blockly.Xml.domToWorkspace(this.generator.generateWorkspaceXml(),
|
||||
this.previewWorkspace);
|
||||
}
|
||||
|
||||
// Update pre-loaded blocks in the preview workspace.
|
||||
this.previewWorkspace.clear();
|
||||
Blockly.Xml.domToWorkspace(this.generator.generateWorkspaceXml(),
|
||||
this.previewWorkspace);
|
||||
|
||||
// Reenable events.
|
||||
Blockly.Events.enable();
|
||||
};
|
||||
|
||||
@@ -301,7 +301,8 @@ WorkspaceFactoryModel.prototype.clearToolboxList = function() {
|
||||
this.toolboxList = [];
|
||||
this.hasVariableCategory = false;
|
||||
this.hasVariableCategory = false;
|
||||
// TODO(evd2014): When merge changes, also clear shadowList.
|
||||
this.shadowBlocks = [];
|
||||
this.selected.xml = Blockly.Xml.textToDom('<xml></xml>');
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user