Get originally selected layer
I want to toggle on and off a layer by name and add it to a keypress via an action. Go me!
var srcDoc = app.activeDocument;
var layerName = "my lovely layer";
srcDoc.activeLayer = srcDoc.artLayers.getByName(layerName);
var vis = srcDoc.activeLayer.visible;
srcDoc.activeLayer.visible = !vis;So far so good. However, I'm a completist and I want to go back to the originally selected layer before hand.
Adding this at the start
var currentLayer = srcDoc.activeLayer;and then using that reference to go back to it :
srcDoc.activeLayer = currentLayer;
Does not work as expected. My script-fu may be weak this morning. -I get mixed results depending on what layer is initially selected and wherther it is visible or not.
Any ideas where I'm going wrong??
Answers, as always, on a postcard...
