diff --git a/blocks_vertical/procedures.js b/blocks_vertical/procedures.js index 5c90d11c24..2029a86f1a 100644 --- a/blocks_vertical/procedures.js +++ b/blocks_vertical/procedures.js @@ -282,8 +282,7 @@ Blockly.ScratchBlocks.ProcedureUtils.createAllInputs_ = function(connectionMap) if (component.substring(0, 1) == '%') { var argumentType = component.substring(1, 2); if (!(argumentType == 'n' || argumentType == 'b' || argumentType == 's' || argumentType == 'f')) { - throw new Error( - 'Found a custom procedure with an invalid type: ' + argumentType); + throw new Error("Found an custom procedure with an invalid type: " + argumentType); } labelText = component.substring(2).trim(); diff --git a/core/connection.js b/core/connection.js index 3ca428c2b5..b6a47ee417 100644 --- a/core/connection.js +++ b/core/connection.js @@ -343,6 +343,10 @@ Blockly.Connection.prototype.checkConnection_ = function(target) { switch (this.canConnectWithReason_(target)) { case Blockly.Connection.CAN_CONNECT: break; + case Blockly.Connection.REASON_CUSTOM_PROCEDURE: + throw 'Trying to replace a shadow on a custom procedure definition.'; + case Blockly.Connection.REASON_SHADOW_PARENT: + throw 'Connecting non-shadow to shadow block.'; case Blockly.Connection.REASON_CHECKS_FAILED: // usb: We allow blocks to be connected into anything through an addon. break; @@ -355,10 +359,6 @@ Blockly.Connection.prototype.checkConnection_ = function(target) { throw 'Attempt to connect incompatible types.'; case Blockly.Connection.REASON_TARGET_NULL: throw 'Target connection is null.'; - case Blockly.Connection.REASON_SHADOW_PARENT: - throw 'Connecting non-shadow to shadow block.'; - case Blockly.Connection.REASON_CUSTOM_PROCEDURE: - throw 'Trying to replace a shadow on a custom procedure definition.'; default: throw 'Unknown connection failure: this should never happen!'; } diff --git a/core/field_textinput_removable.js b/core/field_textinput_removable.js index a37e071845..cf124b5920 100644 --- a/core/field_textinput_removable.js +++ b/core/field_textinput_removable.js @@ -53,6 +53,35 @@ Blockly.FieldTextInputRemovable = function(text, opt_validator, opt_restrictor) }; goog.inherits(Blockly.FieldTextInputRemovable, Blockly.FieldTextInput); +Blockly.FieldTextInputRemovable.prototype.init = function() { + if (this.fieldGroup_) { + // Field has already been initialized once. + return; + } + + var notInShadow = !this.sourceBlock_.isShadow(); + + if (notInShadow) { + this.className_ += ' blocklyEditableLabel'; + } + + Blockly.FieldTextInput.superClass_.init.call(this); + + // If not in a shadow block, draw a box. + if (notInShadow) { + this.box_ = Blockly.utils.createSvgElement('rect', + { + 'x': 0, + 'y': 0, + 'width': this.size_.width, + 'height': this.size_.height, + 'fill': this.sourceBlock_.getColourTertiary(), + } + ); + this.fieldGroup_.insertBefore(this.box_, this.textElement_); + } +}; + /** * Show the inline free-text editor on top of the text with the remove button. * @private