Skip to main content
smithcgl9043167
Inspiring
September 13, 2018
Answered

How to save input values from text box?

  • September 13, 2018
  • 1 reply
  • 3365 views

I searched here and saw a good example using customOptions.

 

 

Why does not my Photoshop recognize this string?

("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8")

 

How to find, get and validate these string so that it works perfectly?

I saw something here but it did not work in any key I generated.

uuidgen

 

Here is a small dialog box with two text boxes that I need to save the values whenever I need to open the window.

dlg = new Window("dialog", "new project", [0, 0, 255, 100], {resizeable: true});
text01 = dlg.add("edittext", {x: 26, y: 26, width: 48, height: 20}, "");
text02 = dlg.add("edittext", {x: 86, y: 26, width: 48, height: 20}, "");
var desc = app.getCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8");
text01.text = desc.getString(0); button = dlg.add("button", [162, 26, 232, 46], "Ok");

button.onClick = function() {
	var desc = new ActionDescriptor(); 
	desc.putString(0, text01.text); 
	app.putCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8", desc, true); 
}

dlg.center();
dlg.show();

Can anyone explain to me how this method works?

This topic has been closed for replies.
Correct answer r-bin

var desc = null;

try { desc = app.getCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8"); } catch (e) {};

if (desc) text01.text = desc.getString(0);

1 reply

r-binCorrect answer
Legend
September 13, 2018

var desc = null;

try { desc = app.getCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8"); } catch (e) {};

if (desc) text01.text = desc.getString(0);

smithcgl9043167
Inspiring
September 13, 2018

Thank you r-bi.

It worked very well. Just a question. To add in other text boxes, do I have to have other individual character keys for each?

Legend
September 13, 2018

In this way

var desc = null; 

try { desc = app.getCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8"); } catch (e) {};  

if (desc)

    {

    text01.text = desc.getString(0);  

    text02.text = desc.getString(1);  

    text03.text = desc.getDouble(stringIDToTypeID("width"));  

    }

...................

................... 

 

        var desc = new ActionDescriptor();   

        desc.putString(0, text01.text);   

        desc.putString(1, text02.text);   

        desc.putDouble(stringIDToTypeID("width"), Number(text03.text));   

        app.putCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8", desc, true);