• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to use slider inside a UI dialog.

Explorer ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied


  Hi !!!

I'm trying to put a slider inside a UI dialog.

This slider will modify the Gausian blur and noise addition value.

Does anyone know if making a slider like this is possible?

below is my script;

//script 


 
 

 

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

function test() {

function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(cTID('Lyr '));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putString(cTID('Nm '), "AJUST");
desc2.putEnumerated(cTID('Md '), cTID('BlnM'), cTID('Ovrl'));
desc2.putBoolean(cTID('FlNt'), true);
desc1.putObject(cTID('Usng'), cTID('Lyr '), desc2);
desc1.putInteger(cTID('LyrI'), 11);
executeAction(sTID('make'), desc1, dialogMode);
};

function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(sTID('newPlacedLayer'), undefined, dialogMode);
};


function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putEnumerated(cTID('Dstr'), cTID('Dstr'), cTID('Gsn '));
desc1.putUnitDouble(cTID('Nose'), cTID('#Prc'), 40.52);
desc1.putBoolean(cTID('Mnch'), true);
desc1.putInteger(cTID('FlRs'), 71345231);
executeAction(sTID('addNoise'), desc1, dialogMode);
};


function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(cTID('Rds '), cTID('#Pxl'), 5.6);
executeAction(sTID('gaussianBlur'), desc1, dialogMode);
};

step1();
step2();
step4();
};

test();



 


//UI
var d = new Window("dialog");
d.text = "adjust the level";
d.preferredSize.width = 227;
d.orientation = "column";
d.alignChildren = ["center","top"];
d.spacing = 10;
d.margins = 16;

var statictext1 = d.add("statictext", undefined, undefined, {name: "statictext1"});
statictext1.text = "Gaussian Blur";
statictext1.justify = "center";
statictext1.alignment = ["center","top"];

var gausianBlurSlider = d.add("slider", undefined, undefined, undefined, undefined, {name: "gausianBlurSlider"});
gausianBlurSlider.minvalue = 0;
gausianBlurSlider.maxvalue = 100;
gausianBlurSlider.preferredSize.width = 202;

var statictext2 = d.add("statictext", undefined, undefined, {name: "statictext2"});
statictext2.text = "Add Noise";
statictext2.justify = "center";
statictext2.alignment = ["center","top"];

var noiseAddSlider = d.add("slider", undefined, undefined, undefined, undefined, {name: "noiseAddSlider"});
noiseAddSlider.minvalue = 0;
noiseAddSlider.maxvalue = 100;
noiseAddSlider.preferredSize.width = 202;



d.show();

 

TOPICS
Actions and scripting

Views

270

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

Yes, it's possible. I didn't try and run your script, as I'm on my phone, but what seems to be the problem?  Why are you specifying the slider values after you define the slider? You have all undefined for the values. The first one is ok, as that is for auto layout. The second one is for the initial value of the slider, the third is for the minimum value, and the last is for the max value. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

I had to remove everything before the GUI to get it to run. I realise that it is a work in progress. Although escape can exit the GUI, it would be best if you had the OK and Cancel buttons working correctly first before worrying about the sliders.

 

slidergui.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

LATEST

First of all, your script is unfunctional. You pasted it without using </> icon during making a post. Please next time to use it if you are looking for help. btw. could you answer for a question I asked in this post: Jul 10, 2021

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines