ardublockly icon indicating copy to clipboard operation
ardublockly copied to clipboard

FieldInstance reload changes field name

Open bmcage opened this issue 8 years ago • 2 comments

Working with the new fieldinstance for stepper. Add two steppers to the workspace: Stepper1 and Stepper2. Now add two move statements, one for Stepper1 and one for Stepper2.

Reload the webpage. Stepper2 move statement is renamed to one of Stepper1. It seems to be due to the unique bool parameter:

      } else {
        // Pick an existing name from the workspace if any exists
        var existingName =
            Blockly.Instances.getAnyInstanceOf(this.instanceType_ , workspace);
        if (existingName) this.setValue(existingName);
      }

So for movement statements the first existingName is selected on rename, as unique == false for these fieldinstances. It seems that if a name is present that is not default name, then the set name must be kept? Or some other way to fix this?

bmcage avatar Oct 21 '16 12:10 bmcage

Possible solution:


      } else {
        // Pick an existing name from the workspace if needed and any exists
        var instanceList =
        Blockly.Instances.allInstancesOf(this.instanceType_,
                                         this.sourceBlock_.workspace);
        if (instanceList.indexOf(this.getValue()) == -1) {
          var existingName =
              Blockly.Instances.getAnyInstanceOf(this.instanceType_ , workspace);
          if (existingName) this.setValue(existingName);
        }
      }

bmcage avatar Oct 21 '16 12:10 bmcage

Hello, did you find a way ? I still have the pb and do not have any idea to resolve it...

SebCanet avatar Jun 07 '17 08:06 SebCanet