Dialogue Box for Two or More Input

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

mohitshu

Dialogue Box for Two or More Input

Post by mohitshu »

Hi
Beside Prompt and Confirm can I have a dialogue box where I can input two or more variable according to the requirement.
pfaffenbichler

Dialogue Box for Two or More Input

Post by pfaffenbichler »

Certainly.
Please check out ScriptUI in the Reference or EXTK’s Help > Object Model Viewer.
Code: Select all#target photoshop
////// create dialog for customer-entry //////
var dlg = new Window('dialog', "save copy", [500,300,820,683]);
dlg.textOne = dlg.add('edittext', [12,15,308,35], ("text 1"), {multiline:false});
dlg.textTwo = dlg.add('edittext', [12,55,308,75], ("text 2"), {multiline:false});
dlg.textOne.active = true;
dlg.checkOne = dlg.add('radiobutton', [12,95,111,115], "variant 1");
dlg.checkTwo = dlg.add('radiobutton', [112,95,209,115], "variant 2");
dlg.checkThree = dlg.add('radiobutton', [210,95,308,115], "variant 3");
dlg.checkOne.value = true;
//////////////////////////////
// ok- and cancel-button;
dlg.cancelBtn = dlg.add('button', [13,340,153,370], 'Cancel', {name:'cancel'});
dlg.okBtn = dlg.add('button', [168,340,307,370], 'OK', {name:'ok'});
//////////////////////////////
dlg.center();
var myReturn = dlg.show ();
if (myReturn == true) {
if (dlg.checkOne.value == true) {var theVariant = "variant 1"};
if (dlg.checkTwo.value == true) {var theVariant = "variant 2"};
if (dlg.checkThree.value == true) {var theVariant = "variant 3"};
alert ("the results are\n"+dlg.textOne.text+"\n"+dlg.textTwo.text+"\n"+theVariant)
};
mohitshu

Dialogue Box for Two or More Input

Post by mohitshu »

Thank you very much.... got exactly what I wanted.
pfaffenbichler

Dialogue Box for Two or More Input

Post by pfaffenbichler »

You’re welcome.
mohitshu

Dialogue Box for Two or More Input

Post by mohitshu »

In the above posts I had learned how to make a dialogue box with the help of pfaffenbichler but I have a hard time dealing with the buttons, specially CANCEL button.
What I want from cancel button is if I click on Cancel button then script should stop running.
I have looped all the documents on Photoshop to use the dialogue box.

Code: Select allvar length = app.documents.length;
for(var i=0; i<length; i++)
{
    app.activeDocument = app.documents;
 

var dlg = new Window('dialog', "Input", {x:10, y:10, width:245, height:280});
dlg.main = dlg.add('panel', {x:-5, y:9, width:0, height:0},  ' Width            Height          Dpi');
dlg.main = dlg.add('panel', {x:-5, y:83, width:0, height:0},  '                      ↑Top');
dlg.main = dlg.add('panel', {x:-15, y:132, width:0, height:0},  '← Left                   Ӿ                   Right→');
dlg.main = dlg.add('panel', {x:-15, y:182, width:0, height:0},  '                       ↓Bottom');


dlg.width = dlg.add('edittext', {x:16, y:27, width:60, height:25}, (""), {multiline:false});
dlg.height = dlg.add('edittext', {x:94, y:27, width:60, height:25}, (""), {multiline:false});
dlg.dpi =  dlg.add('edittext', {x:172, y:27, width:60, height:25}, (""), {multiline:false});
dlg.margin_top = dlg.add('edittext', {x:95, y:100, width:50, height:20}, (""), {multiline:false});
dlg.margin_left = dlg.add('edittext', {x:45, y:130, width:50, height:20}, (""), {multiline:false});
dlg.margin_bottom = dlg.add('edittext', {x:95, y:160, width:50, height:20}, (""), {multiline:false});
dlg.margin_right = dlg.add('edittext', {x:145, y:130, width:50, height:20}, (""), {multiline:false});

dlg.width.active = true;

// ok- and cancel-button;
dlg.okBtn = dlg.add('button', {x:20, y:230, width:90, height:30}, 'OK', {name:'ok'});

dlg.cancelBtn = dlg.add('button', {x:135, y:230, width:90, height:30}, 'Cancel', {name:'cancel'});

//dlg.cancelBtn.onClick = function(){}

///////////////////////////////////////////////
dlg.center();
var myReturn = dlg.show ();
}
pfaffenbichler

Dialogue Box for Two or More Input

Post by pfaffenbichler »

myReturn from the line
Code: Select allvar myReturn = dlg.show ();
is 1 if the dialog was OK-ed, 2 if it was canceled.
So you could wrap the following code in the appropriate if-clause.
mohitshu

Dialogue Box for Two or More Input

Post by mohitshu »

Thank you very much.... mohitshu wrote:Hi
Beside Prompt and Confirm can I have a dialogue box where I can input two or more variable according to the requirement.
Thankyou Very much pfaffenbichler.