• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Check if Window Element is currently active

Engaged ,
Oct 22, 2016 Oct 22, 2016

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.

TOPICS
Actions and scripting

Views

381

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 22, 2016 Oct 22, 2016

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

...

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 22, 2016 Oct 22, 2016

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 ()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 23, 2016 Oct 23, 2016

Copy link to clipboard

Copied

Thanks, this works great!  I didn't realize something like that would work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2016 Oct 23, 2016

Copy link to clipboard

Copied

LATEST

Glad it works for you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines