Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyMakesThings committed Sep 29, 2024
1 parent 42c52b7 commit 752aa88
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
3 changes: 1 addition & 2 deletions blocks_vertical/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 4 additions & 4 deletions core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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!';
}
Expand Down
29 changes: 29 additions & 0 deletions core/field_textinput_removable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 752aa88

Please sign in to comment.