Skip to main content
Participant
May 14, 2011
Answered

Continue or Cancel alert dialog within JSX

  • May 14, 2011
  • 1 reply
  • 5375 views

Sorry folks another newbie here - both to scripting and pshop scripting. So please excuse such a basic question but I am having a little trouble with an alert box that I added to top of some javascript I grabbed from the listener.

I want to be able to display an alert dialog to the user asking them to ensure their image meets certain requirements before continuing. Something like 'make sure your image is like this before continuing. Continue or Cancel'. When the user hits the continue button the rest of the javascript runs but if they hit the cancel button the script is aborted.

All I have been able to do is show a dialog before the script starts and then instruct the user to hit Okay to continue and press the ESC key to abort. Not very elegant and only works on Windows not Mac machines.

Any help or ideas would be fab.

Cheers,

Philip

This topic has been closed for replies.
Correct answer c.pfaffenbichler

Check out

»confirm«

in ESTK’s Help > Object Model Viewer in the Core JavaScript Classes.

1 reply

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
May 14, 2011

Check out

»confirm«

in ESTK’s Help > Object Model Viewer in the Core JavaScript Classes.

c.pfaffenbichler
Community Expert
Community Expert
May 14, 2011

You would have to wrap the subsequent Script-elements in an if-clause like

var result = confirm("continue or stop", false);

if (result == true) {

// insert your code

};

I want to be able to display an alert dialog to the user asking them to ensure their image meets certain requirements before continuing.

What requirements are those?

Might it be possible to have the Script check those conditions?

Participant
May 14, 2011

Okay now I get it. I have added the listener script in between curly brackets of the if-clause and that is working well.

Yes I agree that it would be better for the script to interigate the document to see if it meets the requirements and then only display the alert if it doesn't but my scripting abilities are so basic that this is beyond me at the moment.

I want to build my skills and add this variation into the next project.

cheers for the help

philip