How to use slider inside a UI dialog.
//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();