我已经实现了一个上下文菜单处理程序,它将一个块添加到工作区。我试图在召唤上下文菜单的块和可能已连接到它的任何块(previousConnection)之间添加块。我正在拍摄的内容和我已经获得的代码以及它的作用......
SurfaceTexture
答案 0 :(得分:0)
//create comment block and get the block that summoned the context menu
var comment = workspace.newBlock('ta_comment');
var block = Blockly.ContextMenu.currentBlock;
//connect up comment block
comment.previousConnection.connect(block.previousConnection.targetConnection);
comment.nextConnection.connect(block.previousConnection);
//init
comment.initSvg();
//render updated workspace
workspace.render();