Copy link to clipboard
Copied
I mean when I'm executing a script,if I want break a loop, I can just press the "Esc" key.I think this is very handly.But I also want to call a function when "Esc" is pressed,is this possible, and how can I do this?
Copy link to clipboard
Copied
Taken from Peter Kahrel's UI guide.
http://www.kahrel.plus.com/indesign/scriptui-2-0.pdf
So escape could be captured by if(myWindow.show()==2){do stuff }?
the user clicks OK (which in this script corresponds to pressing Enter) or they can click
Cancel (which is the equivalent of pressing Escape). The window's behaviour is
this: if the user presses OK, the line myWindow.show ( ) returns 1, if they press
Esc, that line returns 2. We capture this as follows:
if (myWindow.show () == 1)
var myName = myText.text;
else
exit ();