Skip to main content
Inspiring
February 17, 2019
Question

Detect when user clicks or changes layer?

  • February 17, 2019
  • 1 reply
  • 1256 views

I have a script that is very sensitive to which layer is currently selected. If user would change that selection – script will break.

I would like to stop my script completely if user clicks anywhere in the layers or channels tabs of Photoshop.

Is there a way to do that? Maybe some kind of event when layers or channels change?

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
February 17, 2019

A user can not change the active layer while a script is running,  If a script is designed to work ob a particular layer then script should either  activate the layer or require the user to target the proper layer before running the script.  A scirpt can gets all the layer in a document and make any one of the the current active layer.  The Script needs some way to know which layer is to be changed though. Some convection like layer kind with a layer name  or partial name xyz.

JJMack
AverinAAAAuthor
Inspiring
February 17, 2019

My script is interactive and allows user to input some values in my panel extensions.

Still, if user changes the layer or values, all interactivity would break

JJMack
Community Expert
Community Expert
February 17, 2019

If your script gives a user interactive control of Photoshop and allows a user to change value and active layer etc. Your script needs to handle that. It should record these important things in variable or in script options or in document metadata or in system environment variable before giving the user interactive control. When the user returns control or runs your script to give control to your script again your script should use any recorded saved setting to get the document back into the required state.  It is your script, your process. You need to implement a process that works no matter what you allow the user to do.  I would not expect you to be able to handle the condition of a user deleting the layer in question.

JJMack