Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to generate a "control_if"(if, elseif, else) block by Javascript in my workspace?

30 views
Skip to first unread message
Message has been deleted

ziyang

unread,
Apr 15, 2025, 11:45:23 AMApr 15
to Blockly
Hello! I'm trying convert Python Code to Blockly by analyzing Python AST. I know how to generate "if" block like this:
screenshot-20250415-155909.png
screenshot-20250415-155954.png
But how do I to create a “if” block with “else if” and “else”?like this:
20250415-160254.jpg

Ronald Bourret

unread,
Apr 15, 2025, 12:03:15 PMApr 15
to blo...@googlegroups.com
const ifBlock = workspace.newBlock('controls_if');
ifBlock.loadExtraState({elseIfCount: 2, hasElse: true});
ifBlock.initSvg();

Ronald Bourret
Technical Writer (Provided by Synergis)


--
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 visit https://groups.google.com/d/msgid/blockly/0bde4d79-bfa1-44a2-aa6f-fc7d6a26907bn%40googlegroups.com.

ziyang

unread,
Apr 16, 2025, 11:27:57 AMApr 16
to Blockly
Great! Thank you for your help sincerely!
Reply all
Reply to author
Forward
0 new messages