Blockly.Blocks['myblock'] = {
init: function() {
this.appendDummyInput()
.appendField("hello")
.appendField(new Blockly.FieldVariable("item"), "MYVAR");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(20);
this.setTooltip('');
this.setHelpUrl('http://www.example.com/');
}
};
Blockly.JavaScript['myblock'] = function(block) {
var myvar = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('MYVAR'), Blockly.Variables.NAME_TYPE);
alert(myvar);
var code = 'alert("got something: " + ' + myvar + ');';
return code;
};

var myvar = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('MYVAR'), Blockly.Names.VARIABLE);
--
You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/JzVgbKEcyaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/ff703336-c4c2-4352-9bb4-44c042fd0f51n%40googlegroups.com.