mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Add test block for field image with a click handler (#3642)
This commit is contained in:
@@ -191,6 +191,10 @@ Blockly.FieldImage.prototype.initView = function() {
|
||||
this.fieldGroup_));
|
||||
this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS,
|
||||
'xlink:href', /** @type {string} */ (this.value_));
|
||||
|
||||
if (this.clickHandler_) {
|
||||
this.imageElement_.style.cursor = 'pointer';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1340,6 +1340,20 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
|
||||
}
|
||||
]); // END JSON EXTRACT (Do not delete this comment.)
|
||||
|
||||
Blockly.Blocks['test_images_clickhandler'] = {
|
||||
init: function() {
|
||||
this.appendDummyInput()
|
||||
.appendField("Image click handler")
|
||||
.appendField(new Blockly.FieldImage(
|
||||
"https://blockly-demo.appspot.com/static/tests/media/a.png", 32, 32,
|
||||
"image with click handlder", this.onClick_), "IMAGE");
|
||||
this.setStyle('text_blocks');
|
||||
},
|
||||
onClick_: function() {
|
||||
alert('Image clicked');
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_validators_text_null'] = {
|
||||
init: function() {
|
||||
this.appendDummyInput()
|
||||
|
||||
@@ -1608,6 +1608,7 @@ var spaghettiXml = [
|
||||
<block type="test_images_fliprtl"></block>
|
||||
<block type="test_images_missing"></block>
|
||||
<block type="test_images_many_icons"></block>
|
||||
<block type="test_images_clickhandler"></block>
|
||||
</category>
|
||||
<category name="Emoji! o((*^ᴗ^*))o">
|
||||
<label text="Unicode & Emojis"></label>
|
||||
|
||||
Reference in New Issue
Block a user