Hi All,--
I am using custom block in my project and want to perform some action on click of an element. I am using next statement to perform some action but I don't know how to get value of next statement in custom block for JavaScript. Blockly.JavaScript.statementToCode is working for StatementInput but What method should use for next statement. Here I am pasting the UI of my block:Thanks
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/81cec872-0229-4982-b724-42ac42f9a3af%40googlegroups.com.
Thanks for your reply but I have tried workspaceToCode as well as blockToCode but failed to get the expected output, may be I don't know how to use it properly. I am writing my expected output of above blogs, so it will be easy to understand the question:document.getElementById("button-0").onclick = function(){document.getElementById("panel-0-0").style.backgroundColor = '#ff0000'/*** I want to attach many blocks below my first block and want their value here **/}And I am new to blockly, So If it is possible then please send me one example to develop these things. It will be very helpful for me.
Thanks
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/5eb10904-77ca-4795-b7db-97131e530df7%40googlegroups.com.
Hi I am sending you the code of first block "simpleEvent" in which I have used appendStatementInput and it is working fine for that but I dont want to use appendStatementInput and want output like it is coming right now::CODE:Blockly.Blocks['simpleEvent'] = {currentValue: -1,init: function() {this.appendDummyInput().appendField('On').appendField(new Blockly.FieldDropdown(this.getElementIdLst, this.elementSelectionListener), 'ElementId').appendField('Event').appendField(new Blockly.FieldDropdown(this.generatePropertyOptions, this.elementAttributeListener), 'EventId')this.setColour(160)this.setNextStatement(true)this.setPreviousStatement(true)this.appendStatementInput('DO')this.currentValue = this.getFieldValue('ElementId')},Blockly.JavaScript['simpleEvent'] = function(block) {var code = '';if(block.getFieldValue('ElementId')){let elementId = block.getFieldValue('ElementId')if(block.getFieldValue('EventId') == 'CLICK'){code += 'document.getElementById("'+elementId+'").onclick = function(){\n'}else if(block.getFieldValue('EventId') == 'OnDblClick'){code += 'document.getElementById("'+elementId+'").ondblclick = function(){\n'}else if(block.getFieldValue('EventId') == 'MouseOver'){code += 'document.getElementById("'+elementId+'").onmouseover = function(){\n'}else if(block.getFieldValue('EventId') == 'MouseLeave'){code += 'document.getElementById("'+elementId+'").onmouseleave = function(){\n'}var statements_name = Blockly.JavaScript.statementToCode(block, 'DO');if(statements_name){code += Blockly.JavaScript.INDENT+statements_name+'\n';}code += '}\n'}return code}
OUTPUT:
document.getElementById("button-0").onclick = function(){
document.getElementById("panel-0-2").style.display = (((document.getElementById("panel-0-1").style.display == "none" ? false: true)==true||(document.getElementById("panel-0-1").style.display == "none" ? false: true)=="true"||(document.getElementById("panel-0-1").style.display == "none" ? false: true)==1||(document.getElementById("panel-0-1").style.display == "none" ? false: true)=="1")?"block":"none");document.getElementById("panel-0-2").style.backgroundColor = '#ff0000'}
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/92c26daa-4c0b-44fa-a4c7-d4b8c6f2b7f7%40googlegroups.com.
Hi,thanks for the clarification. It means I should still use statement input instead of next statement?
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/CAFE_sBHCpB_d_-WDQ-3XgJkphZbOB1AO0q9%2BuAJNQQKCYaBYOQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/CAF_JBeJ_gVRFoQAYV0w0GXMqozKriu7X_D9kNAs7zypzu1%3DsKA%40mail.gmail.com.