

During the development process, I discovered an abnormal output in a Blocky or Scratch block that caused concern.
For example, the 'math_arithmetic' block when executing should output . However, Scratch outputs , while Blockly outputs '1a'. This inconsistency and non-standard behavior could lead to students developing incorrect learning/understanding.
If it produced , the Scratch program should ideally be stopped, rather than outputting to allow Scratch to continue executing erroneously. This potentially leads to students forming poor programming habits or being unable to find errors, which is a detrimental outcome.



H i,
I have successfully created a new field inheriting from FieldLabelSerializable to display an oval background with text, and this field allows for custom background and text colors. If there are any best practices or correct implementation details for this code, please feel free to guide me. The next step is to extend this program to create a field where the background shape can be configured as an oval, a diamond, or a rectangle.blocks.js
Blockly.Blocks['test'] = {
init: function() {
this.appendDummyInput()
.appendField(new FieldZelosOvalBackground('Taiwan', '#FFFFFF', '#FD6723', null));
this.appendDummyInput()
.appendField(new FieldZelosOvalBackground('Hello', '#FFFFFF', '#CC9900', null));
this.appendDummyInput()
.appendField(new FieldZelosOvalBackground('World', '#FFFFFF', '#59C059', null));
this.setPreviousStatement(0);
this.setNextStatement(!0);
this.setStyle('control_blocks');
}
};
Blocklycompressed.js
class FieldZelosOvalBackground extends Blockly.FieldLabelSerializable {
static KEY_ = 'field_zelos_oval_bg';
static getRoundRectPath(x, y, width, height, radius) {
return `M ${x + radius},${y}
h ${width - 2 * radius}
a ${radius},${radius} 0 0 1 ${radius},${radius}
v ${height - 2 * radius}
a ${radius},${radius} 0 0 1 -${radius},${radius}
h -${width - 2 * radius}
a ${radius},${radius} 0 0 1 -${radius},-${radius}
v -${height - 2 * radius}
a ${radius},${radius} 0 0 1 ${radius},-${radius}
z`;
}
constructor(value, text_color, background_color, opt_config) {
super(value || ' ', opt_config);
this.textColor_ = text_color || '#FFFFFF';
this.backgroundColor_ = background_color || '#FD6723';
}
initView() {
super.initView();
if (this.fieldBorderRect_) {
this.fieldBorderRect_.remove();
}
this.fieldBorderRect_ = Blockly.utils.dom.createSvgElement(
Blockly.utils.Svg.PATH,
{
'class': 'blocklyFieldRect blocklyFieldZelosOvalPath',
'fill': '#FFFFFF',
'stroke': '#FFFFFF'
},
this.fieldGroup_
);
this.fieldGroup_.insertBefore(this.fieldBorderRect_, this.textElement_);
this.textElement_.style.fill = this.textColor_;
this.applyColour();
}
applyColour() {
if (!this.fieldBorderRect_) {
return;
}
this.fieldBorderRect_.setAttribute('fill', this.backgroundColor_);
this.fieldBorderRect_.setAttribute('stroke', this.backgroundColor_);
if (this.textElement_) {
this.textElement_.style.fill = this.textColor_;
}
}
showEditor_() {
}
updateSize_() {
super.updateSize_();
if (!this.fieldBorderRect_ || !this.sourceBlock_ || !this.sourceBlock_.workspace.getRenderer()) {
return;
}
const renderer = this.sourceBlock_.workspace.getRenderer();
const constants = renderer.getConstants ? renderer.getConstants() : renderer.constants_;
let fieldHeight = 30;
const cornerRadius = fieldHeight / 2;
const textWidth = this.textElement_.getComputedTextLength();
const totalWidth = textWidth + cornerRadius*2;
this.size_.width = totalWidth;
const d = FieldZelosOvalBackground.getRoundRectPath(
0, 0,
totalWidth,
fieldHeight,
cornerRadius
);
this.fieldBorderRect_.setAttribute('d', d);
const translateX = 0;
const translateY = -4;
this.fieldBorderRect_.setAttribute('transform', `translate(${translateX}, ${translateY})`);
let textPadding = 14;
this.textElement_.setAttribute('x', textPadding);
this.applyColour();
}
}
Blockly.FieldZelosOvalBackground = FieldZelosOvalBackground;
Blockly.registry.register(
Blockly.registry.Type.FIELD,
FieldZelosOvalBackground.KEY_,
FieldZelosOvalBackground
);
fu6...fu6...@gmail.com 在 2025年10月14日 星期二上午10:38:04 [UTC+8] 的信中寫道:
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/blockly/ba7938c6-6cff-4c80-887a-311d091995fcn%40googlegroups.com.

To view this discussion visit https://groups.google.com/d/msgid/blockly/7e3cbd2e-7171-4f6b-8e00-d87b11b922b7n%40googlegroups.com.
I have successfully mimicked a Scratch functionality where a double-click on a function block's variable field (a FieldLabel) dynamically spawns a variable getter block at the precise cursor location. I have not yet managed to implement the variable block creation using Scratch's signature drag-and-drop mechanism. Please refer to the video demonstration.maxsr...@gmail.com 在 2025年10月20日 星期一下午5:44:27 [UTC+8] 的信中寫道:




To view this discussion visit https://groups.google.com/d/msgid/blockly/25384d22-e85b-4796-b59f-f1f7429c5090n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/blockly/7c7cddc1-35a3-4e0d-bfde-99a84587c13an%40googlegroups.com.
Dear Community,
I am facing an issue with a custom dynamic Flyout category in my Scratch-like platform.
The problem, as shown in the attached video file, occurs when a Procedure Definition block is deleted from the workspace, the dynamic Flyout still incorrectly displays its corresponding Call and Variable blocks upon reopening.
I have confirmed that the flyoutCategory function correctly generates an array of blocks (console.log(blocks) is correct), showing only current procedures. The issue appears during the Flyout's visual rendering, which seems to display stale data related to the deleted function.
Any help with this data inconsistency/caching issue in dynamic Flyouts is greatly appreciated.
