mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
JSON support for message lookup in colour, tooltip, and help URL. (#825)
String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean.
This commit is contained in:
committed by
GitHub
parent
560d373c93
commit
4fdd16b499
@@ -432,31 +432,25 @@ Blockly.Blocks['logic_negate'] = {
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['logic_boolean'] = {
|
||||
/**
|
||||
* Block for boolean data type: true and false.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "BOOL",
|
||||
"options": [
|
||||
["%{bky_logic_boolean_true}", "TRUE"],
|
||||
["%{bky_logic_boolean_false}", "FALSE"]
|
||||
]
|
||||
}
|
||||
],
|
||||
"output": "Boolean",
|
||||
"colour": Blockly.Blocks.logic.HUE,
|
||||
"tooltip": Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP,
|
||||
"helpUrl": Blockly.Msg.LOGIC_BOOLEAN_HELPURL
|
||||
});
|
||||
}
|
||||
};
|
||||
// Block for boolean data type: true and false.
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "logic_boolean",
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_dropdown",
|
||||
"name": "BOOL",
|
||||
"options": [
|
||||
["%{BKY_LOGIC_BOOLEAN_TRUE}", "TRUE"],
|
||||
["%{BKY_LOGIC_BOOLEAN_FALSE}", "FALSE"]
|
||||
]
|
||||
}
|
||||
],
|
||||
"output": "Boolean",
|
||||
"colour": "%{BKY_LOGIC_HUE}",
|
||||
"tooltip": "%{BKY_LOGIC_BOOLEAN_TOOLTIP}",
|
||||
"helpUrl": "%{BKY_LOGIC_BOOLEAN_HELPURL}"
|
||||
}]);
|
||||
|
||||
Blockly.Blocks['logic_null'] = {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user