mirror of
https://github.com/google/blockly.git
synced 2026-01-16 21:37:10 +01:00
Added getSourceBlock function to field. (#2508)
This commit is contained in:
@@ -250,7 +250,7 @@ Blockly.DropDownDiv.showPositionedByField = function(owner,
|
||||
// Set bounds to workspace; show the drop-down.
|
||||
Blockly.DropDownDiv.positionToField_ = true;
|
||||
Blockly.DropDownDiv.setBoundsElement(
|
||||
owner.sourceBlock_.workspace.getParentSvg().parentNode);
|
||||
owner.getSourceBlock().workspace.getParentSvg().parentNode);
|
||||
return Blockly.DropDownDiv.show(
|
||||
owner, primaryX, primaryY, secondaryX, secondaryY, opt_onHide);
|
||||
};
|
||||
@@ -514,7 +514,7 @@ Blockly.DropDownDiv.repositionForWindowResize = function() {
|
||||
// when a field is focused, the soft keyboard opens triggering a window resize
|
||||
// event and we want the dropdown div to stick around so users can type into it.
|
||||
if (Blockly.DropDownDiv.owner_) {
|
||||
var block = Blockly.DropDownDiv.owner_.sourceBlock_;
|
||||
var block = Blockly.DropDownDiv.owner_.getSourceBlock();
|
||||
var scale = block.workspace.scale;
|
||||
var bBox = {
|
||||
width: Blockly.DropDownDiv.positionToField_ ?
|
||||
|
||||
@@ -211,6 +211,14 @@ Blockly.Field.prototype.setSourceBlock = function(block) {
|
||||
this.sourceBlock_ = block;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the block this field is attached to.
|
||||
* @return {Blockly.Block} The block containing this field.
|
||||
*/
|
||||
Blockly.Field.prototype.getSourceBlock = function() {
|
||||
return this.sourceBlock_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize everything to render this field. Override
|
||||
* methods initModel and initView rather than this method.
|
||||
|
||||
@@ -163,11 +163,11 @@ Blockly.Procedures.rename = function(name) {
|
||||
name = name.replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');
|
||||
|
||||
// Ensure two identically-named procedures don't exist.
|
||||
var legalName = Blockly.Procedures.findLegalName(name, this.sourceBlock_);
|
||||
var legalName = Blockly.Procedures.findLegalName(name, this.getSourceBlock());
|
||||
var oldName = this.text_;
|
||||
if (oldName != name && oldName != legalName) {
|
||||
// Rename any callers.
|
||||
var blocks = this.sourceBlock_.workspace.getAllBlocks(false);
|
||||
var blocks = this.getSourceBlock().workspace.getAllBlocks(false);
|
||||
for (var i = 0; i < blocks.length; i++) {
|
||||
if (blocks[i].renameProcedure) {
|
||||
blocks[i].renameProcedure(oldName, legalName);
|
||||
|
||||
Reference in New Issue
Block a user