class WaitIcon extends Blockly.icons.Icon {
getType() {
return new Blockly.icons.IconType('wait_icon');
}
getSize() {
return new Blockly.utils.Size(16, 16);
}
getWeight() {
return 10;
}
initView(pointerdownListener) {
if (this.svgRoot) return; // Already initialized.
// This adds the pointerdownListener to the svgRoot element.
// If you do not call `super` you must do this yourself.
super.initView(pointerdownListener);
Blockly.utils.dom.createSvgElement(
Blockly.utils.Svg.CIRCLE,
{
'class': 'my-css-class',
'r': '8',
'cx': '8',
'cy': '8',
},
this.svgRoot // Append to the svgRoot.
);
}
onClick() {
// Do something when clicked.
}
isShownWhenCollapsed() {
return true;
}
updateEditable() {
if (this.sourceBlock.isEditable()) {
// Do editable things.
} else {
// Do non-editable things.
}
}
updateCollapsed() {
// By default icons are hidden when the block is collapsed. We want it to
// be shown, so do nothing.
}
}
Blockly.icons.registry.register(
new Blockly.icons.IconType('wait_icon'), WaitIcon);