Save/Load User Inputs from Scripted GUI in ExtendScript

What type of scripts do you need?

Moderator: byronnash

Post Reply
AndyTroz
Posts: 5
Joined: March 29th, 2009, 12:18 pm

I've created a very simple GUI in ExtendScript and I'd like to know how to save and load any user inputs from the "edittext" boxes that I've created.

Code: Select all

//GUI Design
var myWin = new Window ("palette", "EditTextTest", undefined);
myWin.orientation = "row";

var groupOne = myWin.add("group", undefined, "GroupOne");
groupOne.orientation = "column";
groupOne.add("statictext", undefined, "Player 01 Name");
var etOne = groupOne.add("edittext", undefined, "");
etOne .characters = 10;
groupOne.add("statictext", undefined, "Player 02 Name");
var etTwo = groupOne.add("edittext", undefined, "");
etTwo .characters = 10;
groupOne.add("statictext", undefined, "Player 03 Name");
var etThree = groupOne.add("edittext", undefined, "");
etThree .characters = 10;
groupOne.add("statictext", undefined, "Player 04 Name");
var etFour = groupOne.add("edittext", undefined, "");
etFour .characters = 10;
groupOne.add("statictext", undefined, "Player 05 Name");
var etFive = groupOne.add("edittext", undefined, "");
etFive .characters = 10;

myWin.center();
myWin.show();
Attachments
EditTextTest.jpg
EditTextTest.jpg (40.03 KiB) Viewed 9084 times
beginUndoGroup
Posts: 81
Joined: November 27th, 2012, 6:41 am

Hello,
there is nothing to do: the text content is an attribute of the text container.
You can set it from within the script exactly as you set the characters attribute
(for instance etOne.text = 'Mario' sets the text to Mario). If the user changes the text input the text attribute is changed accordingly.
You can also force a specific format.
For instance:
etOne.onChange = function(){this.text = this.text.toUpperCase();}
or
etOne.onChange = function(){this.text = isNaN(parseFloat(this.text)) ? 100 : parseFloat(this.text);}

If all text containers have the same behaviour, you'd better define a single function:
function format(){this.text = this.text.toUpperCase();}
and then define
etOne.onChange = etTwo.onChange = etThree.onChange = etFour.onChange = format;
Post Reply