Write path to text box

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

applezap

Write path to text box

Post by applezap »

I am working a creating a window that lets you choose a file path that you wish to export some files to (there is more to it than just the code below, but I'll leave that out of it for now).

Toward the bottom, I have a function that allows you to click a button and choose your path, but I want the path to show in the text box several lines above. Can anyone help me with that?

Thanks!

Code: Select all
var win = new Window ("dialog", "Export Textures 1.0", );
win.preferredSize =[300, 200];
win.alignChildren ="left";

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Choose the size you want to export the textures to
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

win.add ("statictext", undefined, "Please choose a texture output size:");
var size256 = win.add ("radiobutton", undefined, "256");
var size512= win.add ("radiobutton", undefined, "512");
var size1024 = win.add ("radiobutton", undefined, "1024");
var size2048= win.add ("radiobutton", undefined, "2048");

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Choose an output path
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var g1 = win.add ("group");
var et1 = win.add ("edittext").preferredSize = [350,20];
var buttonPath = win.add ("button", undefined, "Choose Path");
buttonPath.onClick = function () {
    var outputFolder = Folder.selectDialog("Please select the output folder");
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Show the window
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

win.show ()


Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Write path to text box

Post by Mike Hale »

Code: Select all// ...
 var et1 = win.add ("edittext");// add control then
    et1.preferredSize = [350,20];// set size or et1 will hold an array instead of a UI control object
    var buttonPath = win.add ("button", undefined, "Choose Path");
    buttonPath.onClick = function () {
        var outputFolder = Folder.selectDialog("Please select the output folder");
        // make sure the user didn't cancel then set the edittext control's text property
        if(outputFolder != null) et1.text = decodeURI(outputFolder);
    }
// ...
applezap

Write path to text box

Post by applezap »

Great as usual, thanks so much Mike.