Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions blocks_vertical/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,15 @@ Blockly.ScratchBlocks.ProcedureUtils.updateDeclarationProcCode_ = function() {
this.procCode_ += input.fieldRow[0].getValue();
} else if (input.type == Blockly.INPUT_VALUE) {
// Inspect the argument editor.
var target = input.connection.targetBlock();
this.displayNames_.push(target.getFieldValue('TEXT'));
this.argumentIds_.push(input.name);
if (target.type == 'argument_editor_boolean') {
this.procCode_ += '%b';
} else {
this.procCode_ += '%s';
var target = input.connection ? input.connection.targetBlock() : null;
if (target) {
this.displayNames_.push(target.getFieldValue('TEXT'));
this.argumentIds_.push(input.name);
if (target.type == 'argument_editor_boolean') {
this.procCode_ += '%b';
} else {
this.procCode_ += '%s';
}
}
} else {
throw new Error(
Expand All @@ -649,8 +651,10 @@ Blockly.ScratchBlocks.ProcedureUtils.focusLastEditor_ = function() {
newInput.fieldRow[0].showEditor_();
} else if (newInput.type == Blockly.INPUT_VALUE) {
// Inspect the argument editor.
var target = newInput.connection.targetBlock();
target.getField('TEXT').showEditor_();
var target = newInput.connection ? newInput.connection.targetBlock() : null;
if (target) {
target.getField('TEXT').showEditor_();
}
}
}
};
Expand Down Expand Up @@ -737,7 +741,7 @@ Blockly.ScratchBlocks.ProcedureUtils.removeFieldCallback = function(field) {
var input = this.inputList[n];
if (input.connection) {
var target = input.connection.targetBlock();
if (target.getField(field.name) == field) {
if (target && target.getField(field.name) == field) {
inputNameToRemove = input.name;
}
} else {
Expand Down
12 changes: 12 additions & 0 deletions core/field_customInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ Blockly.FieldCustom.prototype.getValue = function() {
return this.value_;
};

/**
* Get the text from this field for display and XML serialization.
* Return empty string since the actual code is stored in value_ and
* should not be serialized as display text.
* @return {string} Empty string for display.
*/
Blockly.FieldCustom.prototype.getText = function() {
// Return empty string to avoid serializing code with special characters
// The actual value is handled separately via getValue/setValue
return '';
};

/**
* do whatever the user desires on-edit
* @private
Expand Down
Loading