Copy link to clipboard
Copied
Let's say I have the following script in Photoshop CC 2015.1.2 being run by ExtendScript:
var dlg = new Window('dialog', "Window", [0,0,360,240]);
var HeaderName = "Insert Text Here";
dlg.BCVText = dlg.add('edittext', [12,65,100,90], (""), {multiline:false});
dlg.Header1 = dlg.add('statictext',[15,0,100,35], HeaderName)
dlg.Dropdownlist1 = dlg.add('dropdownlist',[12,30,100,55], [1,2,3,4])
if(dlg.BCVText.active == true)
{
var HeaderName = "I'm Selected!";
}
dlg.center();
dlg.show ();
(This code does not do what I want it to)
What I want this code to do is change the dlg.Header1 text to "I'm Selected!" while dlg.BCV.Text is active. So as long as dlg.BCVText (the input text field) is selected by the user (the text field has a blue highlight), the .dlgHeader1 text should change to "I'm Selected!" When the user clicks away (deselcting it) or while anything else is selected, the text of dlg.BCVText should return to "Insert Text Here."
Note, if I click the text field, the text should change. If I click away to deselect it and then click back again, the text should change once more.
In my current example, this is clearly not the case. The if-statement doesn't appear to do anything. I'm not sure how to re-write the if-statement to achieve this. Essentially, I don't know how to get the script to run certain sections of code while the dialog box is still active based on whether or not one of its elements are selected by the user.
Try this:
...var dlg = new Window('dialog', "Window", [0,0,360,240]);
var HeaderName = "Insert Text Here";
dlg.BCVText = dlg.add('edittext', [12,65,100,90], (""), {multiline:false});
dlg.Header1 = dlg.add('statictext',[15,0,100,35], HeaderName)
dlg.Dropdownlist1 = dlg.add('dropdownlist',[12,30,100,55], [1,2,3,4])
dlg.BCVText.onActivate = function(){
dlg.Header1.text = "I'm Selected"
}
dlg.BCVText.onDeactivate= function(){
dlg.Header1.text = "Insert Text
Copy link to clipboard
Copied
Try this:
var dlg = new Window('dialog', "Window", [0,0,360,240]);
var HeaderName = "Insert Text Here";
dlg.BCVText = dlg.add('edittext', [12,65,100,90], (""), {multiline:false});
dlg.Header1 = dlg.add('statictext',[15,0,100,35], HeaderName)
dlg.Dropdownlist1 = dlg.add('dropdownlist',[12,30,100,55], [1,2,3,4])
dlg.BCVText.onActivate = function(){
dlg.Header1.text = "I'm Selected"
}
dlg.BCVText.onDeactivate= function(){
dlg.Header1.text = "Insert Text Here"
}
dlg.center();
dlg.show ()
Copy link to clipboard
Copied
Thanks, this works great! I didn't realize something like that would work.
Copy link to clipboard
Copied
Glad it works for you!