1 Reply Latest reply on May 22, 2017 6:27 PM by Chuck Uebele

    find all top level layers and put in UI

    eyescreamer Level 1

      How do I find all top layers in photoshop document (be it layersets or layers) and have a pop up dialog with those layers in a checkbox list?

        • 1. Re: find all top level layers and put in UI
          Chuck Uebele Adobe Community Professional & MVP

          Try this code. The key is to establish an array to put the checkboxes in and use a loop to create them. When using an onClick function, use "this" to refer to the control rather than the array item.


          #target photoshop
          var doc = activeDocument;
          var layerList = new Array();
          chkList = new Array()
          var dlg= new Window('dialog','Layer List');
          for(var i = 0;i<doc.layers.length;i++){
              chkList[i] = dlg.add('checkbox',undefined,doc.layers[i].name);
              chkList[i].name = doc.layers[i].name;//this assigns a name to the checkbox control that is used in the alert box.
              chkList[i].onClick = function(){