Skip to main content
MidoSemsem
Inspiring
June 22, 2022
Answered

Can I use Esc key to cancel a palette script

  • June 22, 2022
  • 1 reply
  • 410 views

Hi, 

I know it works with a "dialog", but I'm looking for a trick to use (Esc) key to exit a "palette".

 

I made a script palette that contains buttons of the most important scripts I use everyday. I can run different scripts smoothly.

 

The only thing that bothers me is the way to close it then open it and then close it again and so on. 

 

I tried to use it as a "dialog" instead of "palette" but the script buttons won't work unless the main "dialog" script is closed first. This means I will open and close the script for every button click.

 

Kindly help. 

This topic has been closed for replies.
Correct answer MidoSemsem

I found a workaround. i just created a hidden cancelElement button.

////////////////////Close Button
var but = win.add("button", undefined, "Close");
but.size = [0,0];
win.cancelElement = but;
but.onClick = function() {
win.close();
}

 

Works for me anyway.

1 reply

MidoSemsem
MidoSemsemAuthorCorrect answer
Inspiring
June 24, 2022

I found a workaround. i just created a hidden cancelElement button.

////////////////////Close Button
var but = win.add("button", undefined, "Close");
but.size = [0,0];
win.cancelElement = but;
but.onClick = function() {
win.close();
}

 

Works for me anyway.