4 Replies Latest reply on Feb 7, 2016 1:50 PM by Chuck Uebele

    Help Button

    gionnyp9672044 Level 1

      I am creating a small dialog panel

      I would like to add a button with this function

      you think you can do it?

       

      this function

       

      var aLevels = dPanel.add ("checkbox", undefined, "Apply auto levels");

      if (app.documents.length > 0) {

        try {

        if (activeDocument.activeLayer.visible == true) {

        activeDocument.activeLayer.visible = false;

        } else {

        activeDocument.activeLayer.visible = true;

        }

        }

        catch (e) {}

      }

        • 1. Re: Help Button
          Chuck Uebele Adobe Community Professional & MVP

          Do you want a button to click or a checkbox? You have a checkbox mentioned above. To have a button run a function you would use:

           

          var dlg = new Window('dialog','help button');
          dlg.helpButton = dlg.add('button',undefined,'Help Button');
          dlg.helpButton.onClick = function(){
          //your function code here
          dlg.close()//if you want the dialog box to close
          }
          dlg.show()
          
          • 2. Re: Help Button
            gionnyp9672044 Level 1

            I would need a checkbutton

            which has the dual function to enable and disable the selected level.

            • 3. Re: Help Button
              Level 1

              Guys no one has an answer to this problem that has placed gionnyp9672044

              • 4. Re: Help Button
                Chuck Uebele Adobe Community Professional & MVP

                I'm still unclear about what exactly you want to do. a checkbox turns something on or off, which doesn't seem too good for the code you have listed above. If you want a button that turns a layer's viability on or off depending if that layer is visible or not then you can use code like this: add line 4 to your onClick function for a button.

                 

                var doc = activeDocument;
                var layer = doc.activeLayer;
                
                layer.visible = layer.visible == false