Copy link to clipboard
Copied
I am stuck with a problem that I am not sure how to resolve and would like to ask for help from his community.
The Problem:
Canceling the UI dialog via the escape key on the keyboard and the UI Cancel button returns an alert message.
if (!(dialog.show() - 1)) newFunction(radiobutton1, radiobutton2, radiobutton3, radiobutton4, checkbox1);
Copy link to clipboard
Copied
What different do you expect to happen after canceling (escaping) script if in the code at end is alert?
Copy link to clipboard
Copied
After pressing the escape key or cancel button, the UI dialog should terminate completely.
Copy link to clipboard
Copied
if (!(dialog.show() - 1)) newFunction(radiobutton1, radiobutton2, radiobutton3, radiobutton4, checkbox1);
Copy link to clipboard
Copied
Yes enter(Save) your default will terminate the dialog with a return code 1. Cancel and ESC will terminate the dialog with a return code 2.
In any case the script continue. If the script loops an additional ESC should cancel the Script but on Windows and Photoshop it hard to get Photoshop to terminate the running Script. I do not know if the problem is in Photoshop Plug-in Scriptingsupport or in Photoshop. I sure Windows would reflect ESC to the running application Which would be Photoshop or its Plug-in Scriptingsupport. When a script has an ScruptUI dialog being shown ESC is being reflect to dialog.show and it obliging terminates with a return code 2. Photoshop scripts do not have ESC event handlers. So Either Scriptingsupport or Photoshop needs to field the ESC event and terminate the Script some way.
Its easy to test to see if dialog show was canceled. Other dialogs like system dialogs Folder and file section can also be tested. Script may be able to set up some kind of event handler for ESC. I do not know for sure. I know you can set up keyboard handlers that are used within ScriptUI because I stole Mike Hale code that only allows some keys to be use in dialog numeric files. Invalid keys are rejected with a beep.
Copy link to clipboard
Copied
He explained to me what he'd like to get, not how he wanted, Photoshop behaved.
Copy link to clipboard
Copied
Thank you Kukurykus!, your suggestion works in a mac environment. The alert dialog does not pop up when using the escape key or the cancel button with a custom script. I will test it further in other scripts. Many thanks!
Copy link to clipboard
Copied
So why you mark your answer as correct, but not mine? 😛
Copy link to clipboard
Copied
It look like ESC end the Show Dialog. Your script the preforms your newfunction that does the alert so its either true of false depending on which radio button is checked. You have set up not cancel test so enter and cancel do the same thing. The script ends after you acknowledge the alert.
Esc Cancelled the Dialog not the script. If fact on windows it often hard to stop a script with ESC or Break. If a script is in an endless loop I usually have to kill Photoshop the stop the a script. I doe not know if its a Photoshop problem of a widows problem. I would think the Photoshop would need to field the ESC and Kill the script. Scripts do not get signal to terminate. The System or Photoshop would need to terminate the script.
Copy link to clipboard
Copied
Sorry, my mistake. I meant to mark your answer as correct.
Copy link to clipboard
Copied
Loll, now you reply outside of subthread, and the answer you marked, was mine indeed, but, not with solution I provided earlier, so I changed it myself eventually 😕
Find more inspiration, events, and resources on the new Adobe Community
Explore Now