onPixelClicked()

in fieldeditors/field_lights.ts [174:187]


    onPixelClicked(e: Event, neopixel: SVGElement, id: number) {
      if (Blockly.utils.isRightButton(e)) return;
      let btn = this.paletteButtons.filter(btn => pxt.BrowserUtils.containsClass(btn, 'active'))[0];
      if (btn) {
        const current = neopixel.getAttribute("data-color");
        const btncol = btn.getAttribute("data-color");
        if (current == btncol)
          neopixel.setAttribute("data-color", "black");
        else
          neopixel.setAttribute("data-color", btncol);
        this.setValue(this.getValueArray())
        if (this.sourceBlock_ && this.sourceBlock_.workspace) (<Blockly.WorkspaceSvg>this.sourceBlock_.workspace).getAudioManager().play('click');
      }
    };