標籤欄位

標籤欄位會將字串儲存為 value,並將字串儲存為 text。標籤欄位的 valuetext 一律相同。

標籤欄位

包含兩列的方塊。第一個標籤為「a label」,第二個標籤為「and another label」。

收合區塊的標籤欄位

收合後的相同區塊。這個標籤只有一列,標示為「a label
and another label」,右側邊緣呈鋸齒狀,表示已收合。

創作

JSON

{
  "type": "example_label",
  "message0": "a label %1 and another label",
  "args0": [
    {
      "type": "input_dummy"
    }
  ]
}

插補引數之間的任何訊息文字都會成為標籤字串。 或者,標籤也可以明確插補為物件或文字。一般不建議這麼做,因為這會增加翻譯難度。

{
  "type": "example_label",
  "message0": "%1 %2 %3",
  "args0": [
    {
      "type": "field_label",
      "text": "a label"
    },
    {
      "type": "input_dummy"
    },
    "and another label"
  ]
}

JavaScript

Blockly.Blocks['example_label'] = {
  init: function() {
    this.appendDummyInput()
        .appendField(new Blockly.FieldLabel('a label'));
    this.appendDummyInput()
        .appendField('and another label');
  }
};

appendField 函式會接受 FieldLabel 物件和 (更常見的) 字串,以建立標籤。

標籤欄位會接收選填值和選填的 CSS 類別字串。 兩者預設值皆為空字串。

序列化

標籤欄位無法序列化。

如要將標籤序列化,因為標籤會以程式輔助方式變更,請參閱「Serializable Label」 欄位。

驗證工具

標籤欄位無法編輯,因此不支援驗證工具。