Commit 1026d353 authored by Neil Fraser's avatar Neil Fraser

Allow blocks in toolbox to be disabled individually.

parent a485e63d
......@@ -149,9 +149,11 @@ Blockly.Flyout.prototype.init = function(targetWorkspace) {
Array.prototype.push.apply(this.eventWrappers_,
Blockly.bindEvent_(this.svgGroup_, 'wheel', this, this.wheel_));
Array.prototype.push.apply(this.eventWrappers_,
Blockly.bindEvent_(this.targetWorkspace_.getCanvas(),
'blocklyWorkspaceChange', this, this.filterForCapacity_));
if (!this.autoClose) {
Array.prototype.push.apply(this.eventWrappers_,
Blockly.bindEvent_(this.targetWorkspace_.getCanvas(),
'blocklyWorkspaceChange', this, this.filterForCapacity_));
}
// Dragging the flyout up and down.
Array.prototype.push.apply(this.eventWrappers_,
Blockly.bindEvent_(this.svgGroup_, 'mousedown', this, this.onMouseDown_));
......@@ -676,8 +678,9 @@ Blockly.Flyout.prototype.filterForCapacity_ = function() {
var blocks = this.workspace_.getTopBlocks(false);
for (var i = 0, block; block = blocks[i]; i++) {
var allBlocks = block.getDescendants();
var disabled = allBlocks.length > remainingCapacity;
block.setDisabled(disabled);
if (allBlocks.length > remainingCapacity) {
block.setDisabled(true);
}
}
};
......
......@@ -114,6 +114,7 @@ Blockly.Toolbox.prototype.init = function() {
}
});
var workspaceOptions = {
disabledPatternId: workspace.options.disabledPatternId,
parentWorkspace: workspace,
RTL: workspace.RTL,
svg: workspace.options.svg
......
......@@ -264,6 +264,7 @@ Blockly.WorkspaceSvg.prototype.addZoomControls_ = function(bottom) {
*/
Blockly.WorkspaceSvg.prototype.addFlyout_ = function() {
var workspaceOptions = {
disabledPatternId: this.options.disabledPatternId,
parentWorkspace: this,
RTL: this.RTL
};
......
......@@ -73,6 +73,7 @@ function start() {
length: 3,
colour: '#ccc',
snap: true},
maxBlocks: Infinity,
media: '../media/',
readOnly: false,
realtime: false,
......@@ -238,6 +239,7 @@ h1 {
</shadow>
</value>
</block>
<block type="controls_repeat" disabled="true"></block>
<block type="controls_whileUntil"></block>
<block type="controls_for">
<value name="FROM">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment