app/assets/htmls/gs-element-blockly.html in gobstones-blockly-0.24.0 vs app/assets/htmls/gs-element-blockly.html in gobstones-blockly-0.24.1

- old
+ new

@@ -3417,10 +3417,11 @@ var callback = Blockly.ContextMenu.callbackFactory(procedureBlock, xmlBlock); return function() { var block = callback(); block.$parent = procedureBlock.id; + block.moveBy(procedureBlock.width, -14); }; }; var getAvailableName = function(self, name) { var result = name; @@ -4065,14 +4066,18 @@ f(newBlock); newBlock.initSvg(); newBlock.render(); }; -const createVariable = (workspace, name) => { - Blockly.createBlockSvg(workspace, 'variables_get', b => { +const createVariable = (parent, name) => { + const workspace = parent.workspace; + Blockly.createBlockSvg(workspace, 'variables_get', b => { b.setFieldValue(name, 'VAR'); - b.moveBy(10,5); + + const posParent = parent.getRelativeToSurfaceXY(); + const pos = b.getRelativeToSurfaceXY(); + b.moveBy(posParent.x - pos.x + parent.width + 16, posParent.y - pos.y + b.height + 6); }); } // --- @@ -4984,11 +4989,11 @@ getLocalMediaSize(handIcon), getLocalMediaSize(handIcon), "Obtener variable", function() { var name = self.getFieldValue('varName'); - createVariable(self.workspace, name); + createVariable(self, name); } ); this.inputList[0].appendField(createGetterButton); } @@ -5171,10 +5176,10 @@ this.createVariableBlock(name); }}); }, createVariableBlock: function(name) { - return createVariable(this.workspace, name); + return createVariable(this, name); } }; Blockly.Blocks.variables_get = { \ No newline at end of file