9 Replies Latest reply on Jan 24, 2018 7:03 AM by JJMack

    Help with tabs in the scriptUI

    Shulipa Bernad Level 1

      Hello friends!

      Normally when we open a dialog box that contains some open, it is normal that when we select one of these tabs, show its respective interface content.

      My question would be:

      Is there any possibility to execute a second function when I select a tab and show its contents:

       

      Example:

      A dialog box has 3 tabs "Color", "Levels" and "Curves"

      If I select the "Levels" tab also perform something like that, it may be an Alert warning: "You have selected the Levels tab".

       

      var dlg = new Window ("dialog", "Abas", [0,0,0,0]);
      dlg.size = [240, 120]
      dlg.location = [415, 230]
      
      
      var tpanel = dlg.add ("tabbedpanel" ,[10,10,0,0],);
      tpanel.size = [220,100];
      dlg.location = [10, 10];
      
      
      var general = tpanel.add ("tab", [0,0,0,0], "Color");
      
      
      var images = tpanel.add ("tab", undefined, "Levels");
      var img_options = images.add ("panel", undefined, "Image Options");
      var buttons = dlg.add ("group");
      buttons.add ("button", undefined, "Export", {name: "ok"});
      buttons.add ("button", undefined, "Cancel");
      
      
      var images1 = tpanel.add ("tab", undefined, "Curves");
      var img_options = images1.add ("panel", undefined, "Image Options");
      var buttons = dlg.add ("group");
      buttons.add ("button", undefined, "Export", {name: "ok"});
      buttons.add ("button", undefined, "Cancel");
      
      
      tpanel.selection = 0;
      dlg.center();
      dlg.show ();
      
        • 1. Re: Help with tabs in the scriptUI
          Kukurykus Adobe Community Professional
          tpanel.onChange = function() {alert(tpanel.selection.text)}
          
          • 2. Re: Help with tabs in the scriptUI
            Shulipa Bernad Level 1

            Hi Kukurykus , thanks for the quick support!

            Just one more question:

            How do I select only one of the tabs, example "Levels"?

            This information is fundamental to the progress of my project.

            1 person found this helpful
            • 3. Re: Help with tabs in the scriptUI
              Kukurykus Adobe Community Professional
              tpanel.onChange = function() {if (tpanel.selection.text == txt = tpanel.children[1].text) alert(txt)} 
              
              1 person found this helpful
              • 4. Re: Help with tabs in the scriptUI
                Shulipa Bernad Level 1

                HiKukurykus thanks again!

                Please, sorry for my lack of knowledge!

                My real goal would be to replace this alert message with a function. but I can not understand your code:

                 

                example:

                By clicking on the "Level" tab,

                Perform this function:

                dlg.size = [240, 320]

                (Increase window height)

                • 5. Re: Help with tabs in the scriptUI
                  Kukurykus Adobe Community Professional

                  Replace 2 lines on top of code you posted higher to:

                   

                  (function shw(v) {  
                       dlg = new Window ("dialog", "Abas", [0,0,0,0])
                       dlg.size = [240, v]
                  

                   

                   

                  then last line of that code change to these lines:

                   

                       tpanel.onChange = function() {if (tpanel.selection.text == tpanel.children[1].text && dlg.size[1] < 320) dlg.close()}  
                       dlg.show ()
                  
                       if (dlg.size[1] < 320) shw(320)
                  })(120)
                  
                  1 person found this helpful
                  • 6. Re: Help with tabs in the scriptUI
                    Shulipa Bernad Level 1

                    Many thanks for the feedback Kukurykus! It was 100% functional: For you this seems very easy. I confess that it is not easy to understand the way you program, so that you can add other functions in other guides!

                     

                    I plan to add other functions to other tabs in future projects!

                    It would be interesting a simplification type:

                    When clicking on a tab, Photoshop will do a task through a Script:

                    My problem is in this part:

                     

                    I do not know if this is possible and if you would still be willing to help me:

                    You could then write a comment like:

                    When you select one of the tabs: perform some function

                    You could create a line with a comment:

                    // Put here the script that performs some function:

                     

                    This is fundamental

                    Eternally grateful!

                    • 7. Re: Help with tabs in the scriptUI
                      Kukurykus Adobe Community Professional

                      IMPORTANT: you probably saved script and ran from Photoshop or kept first dlg preceeded by var (though I missed it) if ran from ESTK with targeted Photoshop; it is why it worked. But if you've ran it from ExtendScript ToolKit without var in front of first dlg then you got error !

                       

                      Here's example of that you wanted (replace alerts with your stuff):

                       

                      tpanel.onChange = function() {
                           if (tpanel.selection.text == tpanel.children[0].text) {
                                alert('Your "Colors" function')
                           }
                      
                           else if(tpanel.selection.text == tpanel.children[1].text) {
                                if (dlg.size[1] < 320) dlg.close()
                                else {
                                     alert('Your "Levels" function')
                                }
                           }
                      
                           else {
                                alert('Your "Curves" function')
                           }
                      } 
                      
                      1 person found this helpful
                      • 8. Re: Help with tabs in the scriptUI
                        Shulipa Bernad Level 1

                        Wow that's amazing! You are a TRUE GENIUS and Gentiu. Now I am very happy and content.

                        Many thanks for your dedication and for sharing your knowledge friend Kukurykus

                        Forever grateful to you!

                         

                        • 9. Re: Help with tabs in the scriptUI
                          JJMack Most Valuable Participant

                          You may want to download and install the image processor Pro script the look ate the code for processing the File type tabs. Its default come with three tabs however the dialog allows you to delete and add tabs to a max of 10 Tabs. You can switch between tabs and see what you have in them and change the settings that are in the tabs..   You can even save configurations you edit.

                          Capture.jpg

                          1 person found this helpful