diff --git a/blockly_compressed.js b/blockly_compressed.js index 108144e9a..522e04dae 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -912,9 +912,8 @@ Blockly.Connection.prototype.targetBlock=function(){return this.targetConnection Blockly.Connection.prototype.bumpAwayFrom_=function(a){if(0==Blockly.dragMode_){var b=this.sourceBlock_.getRootBlock();if(!b.isInFlyout){var c=!1;if(!b.isMovable()){b=a.getSourceBlock().getRootBlock();if(!b.isMovable())return;a=this;c=!0}b.getSvgRoot().parentNode.appendChild(b.getSvgRoot());var d=a.x_+Blockly.SNAP_RADIUS-this.x_;a=a.y_+Blockly.SNAP_RADIUS-this.y_;c&&(a=-a);b.RTL&&(d=-d);b.moveBy(d,a)}}}; Blockly.Connection.prototype.moveTo=function(a,b){this.inDB_&&this.db_.removeConnection_(this);this.x_=a;this.y_=b;this.hidden_||this.db_.addConnection(this)};Blockly.Connection.prototype.moveBy=function(a,b){this.moveTo(this.x_+a,this.y_+b)}; Blockly.Connection.prototype.tighten_=function(){var a=this.targetConnection.x_-this.x_,b=this.targetConnection.y_-this.y_;if(0!=a||0!=b){var c=this.targetBlock(),d=c.getSvgRoot();if(!d)throw"block is not rendered.";d=Blockly.getRelativeXY_(d);c.getSvgRoot().setAttribute("transform","translate("+(d.x-a)+","+(d.y-b)+")");c.moveConnections_(-a,-b)}};Blockly.Connection.prototype.closest=function(a,b,c){return this.dbOpposite_.searchForClosest(this,a,b,c)}; -Blockly.Connection.prototype.checkType_=function(a){var b=this.targetBlock();if(b&&!b.isMovable()&&!this.sourceBlock_.isMovable()||(b=a.targetBlock())&&!b.isMovable()&&!a.getSourceBlock().isMovable())return!1;if(!this.check_||!a.check_)return!0;for(b=0;b=b.height&&(k-=g.height);c?g.width>=a.clientX&&(e+=g.width):a.clientX+g.width>=b.width&&(e-=g.width);Blockly.WidgetDiv.position(e,k,b,f,c);d.setAllowAutoFocus(!0);setTimeout(function(){h.focus()},1);Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()}; Blockly.ContextMenu.hide=function(){Blockly.WidgetDiv.hideIfOwner(Blockly.ContextMenu);Blockly.ContextMenu.currentBlock=null}; diff --git a/core/connection.js b/core/connection.js index 14c07b36f..0d98dbf45 100644 --- a/core/connection.js +++ b/core/connection.js @@ -375,9 +375,8 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate, // Offering to connect the left (male) of a value block to an already // connected value pair is ok, we'll splice it in. - // However, don't offer to splice into an unmovable block. - if (candidate.type == Blockly.INPUT_VALUE && - candidate.targetConnection && + // However, don't offer to splice into an immovable block. + if (candidate.type == Blockly.INPUT_VALUE && candidate.targetConnection && !candidate.targetBlock().isMovable() && !candidate.targetBlock().isShadow()) { return false; @@ -674,17 +673,6 @@ Blockly.Connection.prototype.closest = function(maxLimit, dx, dy) { * @private */ Blockly.Connection.prototype.checkType_ = function(otherConnection) { - // Don't split a connection where both sides are immovable. - var thisTargetBlock = this.targetBlock(); - if (thisTargetBlock && !thisTargetBlock.isMovable() && - !this.sourceBlock_.isMovable()) { - return false; - } - var otherTargetBlock = otherConnection.targetBlock(); - if (otherTargetBlock && !otherTargetBlock.isMovable() && - !otherConnection.getSourceBlock().isMovable()) { - return false; - } if (!this.check_ || !otherConnection.check_) { // One or both sides are promiscuous enough that anything will fit. return true; diff --git a/demos/blockfactory/blocks.js b/demos/blockfactory/blocks.js index 6c59c1d92..5a9752625 100644 --- a/demos/blockfactory/blocks.js +++ b/demos/blockfactory/blocks.js @@ -73,34 +73,36 @@ Blockly.Blocks['factory_base'] = { var bottomExists = this.getInput('BOTTOMTYPE'); if (option == 'LEFT') { if (!outputExists) { - this.appendValueInput('OUTPUTTYPE') - .setCheck('Type') - .appendField('output type'); - this.moveInputBefore('OUTPUTTYPE', 'COLOUR'); + this.addTypeInput_('OUTPUTTYPE', 'output type'); } } else if (outputExists) { this.removeInput('OUTPUTTYPE'); } if (option == 'TOP' || option == 'BOTH') { if (!topExists) { - this.appendValueInput('TOPTYPE') - .setCheck('Type') - .appendField('top type'); - this.moveInputBefore('TOPTYPE', 'COLOUR'); + this.addTypeInput_('TOPTYPE', 'top type'); } } else if (topExists) { this.removeInput('TOPTYPE'); } if (option == 'BOTTOM' || option == 'BOTH') { if (!bottomExists) { - this.appendValueInput('BOTTOMTYPE') - .setCheck('Type') - .appendField('bottom type'); - this.moveInputBefore('BOTTOMTYPE', 'COLOUR'); + this.addTypeInput_('BOTTOMTYPE', 'bottom type'); } } else if (bottomExists) { this.removeInput('BOTTOMTYPE'); } + }, + addTypeInput_: function(name, label) { + this.appendValueInput(name) + .setCheck('Type') + .appendField(label); + this.moveInputBefore(name, 'COLOUR'); + var type = this.workspace.newBlock('type_null'); + type.setShadow(true); + type.outputConnection.connect(this.getInput(name).connection); + type.initSvg(); + type.render(); } };