Makecode Block Annotations
This is a slowly growing list of annotations for blocks in Makecode, mostly to document these for myself whenever I need to write another extensions.
These are annotations that I have seen work in practice.
//% color="#BC986A" icon="\uf0ea"
Change the colour and icon for the namespace - the icon appears to be most valid unicode characters…
Block Body Text
//% block="block text here"
This will replace the default generated block text with the supplied text.
This does not require that the groups be predefined in the namespace.
Place Parameters in the Body Text
//% block="on ClipBit button $button pressed"
Replace $-prefix words with their parameter from the function.
Note that enums will be rendered as their names, rather than their values.
Advanced Blocks - Menu UI
Move the block to the
more section below the main section in the extension menu.
Sets the parameter ‘on’ to use the toggle on/off UI rather an a variable slot
Expandable Blocks (Hidden Parameters)
//% block="set ClipBit $display display to $value || as $style"
|| indicates the point that the block UI will be split, and replaced with an expander
Allow Dragging of Parameters
Map the exported function annotated with this to the C++ call defined in the
shim. Note that this doesn’t make a block by itself, and just exposes the call to Typescript.
If the function in Typescript has a body, this will be used in the sim.
These are annotations that don’t seem to work correctly for Makecode extensions
This (as seen in pxt-microbit here) seems to enumerate enum values and generate a grid of buttons rather than the usual dropdown, except that it doesn’t work for extensions? Specifying these paramters will result in the block not having any parameter for the user to select at all!