1 Reply Latest reply on Mar 3, 2014 1:50 AM by c.pfaffenbichler

    How a dynamic create elements on the form ?

    Andy_Bat1 Level 1

      Hi !

       

      I want to create color elements to form a loop and then contact them via DOM model. On example creates several rectangles, but they have the same name. How to name the objects created in the loop?

       

       

       

      #target photoshop
      
      var color = new Array();
      color[1] = [0.5, 0.5, 0.0, 1] ; //0
      
      wask = new Window('dialog', '');
          wask.orientation = "column";
          wask.alignment="top";
          wask.spacing=0;
              grs1 =wask.add('group');
              grs1.spacing=0;
              grs1.alignment="left";
              grs1.orientation = "column";
          for(var i=1;i<5;i++){
                  myIconButton = grs1 .add('iconbutton', [0,0,0,0], undefined, {style:"toolbutton"}); // <x , ^y , x> , vy
                  myIconButton.size = [20,20];
                  myIconButton.fillBrush = myIconButton.graphics.newBrush(myIconButton.graphics.BrushType.SOLID_COLOR, color[1] ); // iconbutton color
                  myIconButton.text = ""; // didn't use text on iconbutton
                  myIconButton.textPen = myIconButton.graphics.newPen(myIconButton.graphics.PenType.SOLID_COLOR,[0.8,0.6,0.3,1], 1); // text iconbutton color (not used here)
                  myIconButton.helpTip = "Select your color here."
                  myIconButton.onDraw = customDraw;  // function bellow (a must have on any iconbutton so it is drawn correctly
              }
      
      wask.show()
      
      function customDraw() {
          with( this ) {
              graphics.drawOSControl();
              graphics.rectPath(0, 0, size[0], size[1]);
              graphics.fillPath(fillBrush);
      
          }
      }
      
      

       

       

      PrtScr capture_2.jpg