Copy link to clipboard
Copied
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 ();
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(tpa
Copy link to clipboard
Copied
tpanel.onChange = function() {alert(tpanel.selection.text)}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
tpanel.onChange = function() {if (tpanel.selection.text == txt = tpanel.children[1].text) alert(txt)}
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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')
}
}
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
This helped me ! Thank you Kukurykus.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
This helped me. Thank you JJMack.