mirror of
https://github.com/google/blockly.git
synced 2026-01-06 08:30:13 +01:00
Added field_label_serializable. (#2399)
This commit is contained in:
@@ -244,13 +244,33 @@ Blockly.Blocks['field_static'] = {
|
||||
// Text value.
|
||||
init: function() {
|
||||
this.setColour(160);
|
||||
this.appendDummyInput()
|
||||
this.appendDummyInput('FIRST')
|
||||
.appendField('text')
|
||||
.appendField(new Blockly.FieldTextInput(''), 'TEXT');
|
||||
this.setPreviousStatement(true, 'Field');
|
||||
this.setNextStatement(true, 'Field');
|
||||
this.setTooltip('Static text that serves as a label.');
|
||||
this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=88');
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['field_label_serializable'] = {
|
||||
// Text value that is saved to XML.
|
||||
init: function() {
|
||||
this.setColour(160);
|
||||
this.appendDummyInput('FIRST')
|
||||
.appendField('text')
|
||||
.appendField(new Blockly.FieldTextInput(''), 'TEXT')
|
||||
.appendField(',')
|
||||
.appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
|
||||
this.setPreviousStatement(true, 'Field');
|
||||
this.setNextStatement(true, 'Field');
|
||||
this.setTooltip('Static text that serves as a label, and is saved to' +
|
||||
' XML. Use only if you want to modify this label at runtime.');
|
||||
this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=88');
|
||||
},
|
||||
onchange: function() {
|
||||
fieldNameCheck(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -406,6 +406,12 @@ FactoryUtils.getFieldsJs_ = function(block) {
|
||||
// Result: 'hello'
|
||||
fields.push(JSON.stringify(block.getFieldValue('TEXT')));
|
||||
break;
|
||||
case 'field_label_serializable':
|
||||
// Result: new Blockly.FieldLabelSerializable('Hello'), 'GREET'
|
||||
fields.push('new Blockly.FieldLabelSerializable(' +
|
||||
JSON.stringify(block.getFieldValue('TEXT')) + '), ' +
|
||||
JSON.stringify(block.getFieldValue('FIELDNAME')));
|
||||
break;
|
||||
case 'field_input':
|
||||
// Result: new Blockly.FieldTextInput('Hello'), 'GREET'
|
||||
fields.push('new Blockly.FieldTextInput(' +
|
||||
@@ -511,6 +517,13 @@ FactoryUtils.getFieldsJson_ = function(block) {
|
||||
// Result: 'hello'
|
||||
fields.push(block.getFieldValue('TEXT'));
|
||||
break;
|
||||
case 'field_label_serializable':
|
||||
fields.push({
|
||||
type: block.type,
|
||||
name: block.getFieldValue('FIELDNAME'),
|
||||
text: block.getFieldValue('TEXT')
|
||||
});
|
||||
break;
|
||||
case 'field_input':
|
||||
fields.push({
|
||||
type: block.type,
|
||||
|
||||
@@ -421,6 +421,7 @@
|
||||
</category>
|
||||
<category name="Field">
|
||||
<block type="field_static"></block>
|
||||
<block type="field_label_serializable"></block>
|
||||
<block type="field_input"></block>
|
||||
<block type="field_number"></block>
|
||||
<block type="field_angle"></block>
|
||||
|
||||
Reference in New Issue
Block a user