Enable hats per block
See original GitHub issueEach block should be able to define its own “hat”, independent of others. It is currently a global setting defined via Blockly.BlockSvg.START_HAT
.
JSON
The JSON syntax for this should live under a "style"
property.
eg.
{
"name": "some_block",
"style": {
"hat": "cap"
}
...
}
Two values can be specified for "hat"
:
-
"none"
- Flat horizontal top -
"cap"
- Rounded oval with horizontal base
Defining a hat in JSON still follows current rules, where it’s only rendered if the block doesn’t have a previous or output connection.
JavaScript
A hat
property needs to be added to the Block
object.
Additionally, a new JS property should be defined named Blockly.BlockSvg.Style.HAT
(note the added Style
part). This new property accepts the same string values (“none” or “cap”) and is the default hat to use for all blocks without a previous or output connection. This should deprecate Blockly.BlockSvg.START_HAT
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Yes, “true”/“false” doesn’t make sense if multiple hat types can be defined. We can still support it, but it should be removed from documentation.
A user can create a block style with “hat” and then set that block style for their specific block. More information can be found here.