หมวดหมู่ที่ซ้อนกัน

หมวดหมู่สามารถซ้อนอยู่ภายในหมวดหมู่อื่นๆ ได้ ต่อไปนี้คือหมวดหมู่ระดับบนสุด 2 หมวดหมู่ ("หลัก" และ "กำหนดเอง") โดยหมวดหมู่ที่ 2 มีหมวดหมู่ย่อย 2 หมวดหมู่ ซึ่งแต่ละหมวดหมู่มีบล็อก

โปรดทราบว่าหมวดหมู่หนึ่งๆ อาจมีทั้งหมวดหมู่ย่อยและ บล็อก ในตัวอย่างต่อไปนี้ Custom มีหมวดหมู่ย่อย 2 หมวดหมู่ (Move และ Turn) รวมถึงบล็อกของตัวเอง (start)

JSON

{
  "kind": "categoryToolbox",
  "contents": [
    {
      "kind": "category",
      "name": "Core",
      "contents": [
        {
          "kind": "block",
          "type": "controls_if"
        },
        {
          "kind": "block",
          "type": "logic_compare"
        },
      ]
    },
    {
      "kind": "category",
      "name": "Custom",
      "contents": [
        {
          "kind": "block",
          "type": "start"
        },
        {
          "kind": "category",
          "name": "Move",
          "contents": [
            {
              "kind": "block",
              "type": "move_forward"
            }
          ]
        },
        {
          "kind": "category",
          "name": "Turn",
          "contents": [
            {
              "kind": "block",
              "type": "turn_left"
            }
          ]
        }
      ]
    }
  ]
}

XML

<xml id="toolbox" style="display: none">
  <category name="Core">
    <block type="controls_if"></block>
    <block type="logic_compare"></block>
  </category>
  <category name="Custom">
    <block type="start"></block>
    <category name="Move">
      <block type="move_forward"></block>
    </category>
    <category name="Turn">
      <block type="turn_left"></block>
    </category>
  </category>
</xml>