-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Description
Problem statement
Missing APIs in the JSON definitions.
There is no possibility to define a FieldImage opt_onClick via JSON (cf https://github.com/google/blockly/blob/master/core/field_image.js#L73)
More, as the FieldImage has no name attribute, you can't call "this.getField(name)" in an extension to define it.
Expected Behavior
Possibility to define the opt_onclick via JSON like
Blockly.Blocks['test_json'] = {
init: function() {
this.jsonInit({
"type": "test_json",
"message0": "json %1",
"args0": [
{
"type": "field_image",
"src": "https://www.gstatic.com/codesite/ph/images/star_on.gif",
"width": 15,
"height": 15,
"alt": "*",
**"onclick": "myFunction"**
}
],
"colour": 230,
"tooltip": "",
"helpUrl": ""
});
}
};Actual Behavior
You can only define it via javascript
Blockly.Blocks['test_js'] = {
init: function () {
this.appendDummyInput()
.appendField("js")
.appendField(new Blockly.FieldImage("https://www.gstatic.com/codesite/ph/images/star_on.gif", 15, 15, "*", myFunction));
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};
function myFunction(e) {
alert("Clicked");
return 0;
};Additional Information
I post this issue because of my initial message on the Blockly Google group (cf https://groups.google.com/forum/#!topic/blockly/rzcpN8iIrRU)
Thanks,
Best regards,
Jerome.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels