Yikes... it's kind of complicated I think. I haven't really put much thought into how to do this so take this with a grain of salt. I will point you in the right direction in the reference but you will need to do the hard stuff on your own.
The reason I think it is complicated is because... each type of layer is handled differently. When you select a layer inside a group layer than you have to change the way you pick the layers in the script.
You need to look in the reference under a couple of different spots. GroupLayer
MohoDoc
MohoLayer
ScriptInterface
All of these entries in the reference have info about layers.
What you need for setting the setSelLayer is referenced under the MohoDoc. You need to get a layer object first:
"MohoLayer" is what you "get" when you use this. It is the MohoLayer that is the object you need to use setSelLayer().
You need this object in order to change the selected layer. You need to get the layer ID of the next or previous layers in that group.
So you would need to do something like this:
Code: Select all
local group = moho:LayerAsGroup(layer)
Then go to the first layer in that group layer. 0 is the lowest layer. So you could get the "first" layer by using:
Code: Select all
local layer = moho.layer
local layerCount = group:CountLayers()
layerCount -1 would be the first layer of the group (at the top in the layers palette). The layer count is the total but the ID starts at 0... so... -1 gives the correct layer object ID.
You could do this:
Code: Select all
moho:SetSelLayer(group:Layer(layerCount-1))
Once you get to that layer then everything changes because now you aren't on the "group" layer, you are on a layer inside it. Your script would need to account for being on a child layer. You would need to count the layers of the parent group and figure out which one is next.
I think some of this is close, but I haven't really done a lot of tool scripts. I work more with layer scripts which are a bit different. I hope I don't steer you in the wrong direction.
-vern