Skip to main content
Shulipa Bernad
Inspiring
January 22, 2018
Answered

Help with tabs in the scriptUI

  • January 22, 2018
  • 2 replies
  • 2602 views

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 ();

This topic has been closed for replies.
Correct answer Kukurykus

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!


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')

     }

}

2 replies

JJMack
Braniac
January 24, 2018

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.

JJMack
Inspiring
September 7, 2022

This helped me. Thank you JJMack.

Kukurykus
Braniac
January 22, 2018

tpanel.onChange = function() {alert(tpanel.selection.text)}

Shulipa Bernad
Inspiring
January 22, 2018

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.

Kukurykus
KukurykusCorrect answer
Braniac
January 23, 2018

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!


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')

     }

}