mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Allow blocks in toolbox to be disabled individually.
This commit is contained in:
parent
a485e63df2
commit
1026d353ce
4 changed files with 12 additions and 5 deletions
|
@ -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">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue