"Previous Layer" doesn't really go to previous layer

Hi! I’ve noticed a weird behaviour of the command Edit > Other > Previous/Next Layer.

If I have a file with one master and several non-master layers, this command switches between Regular and Layer 1, and then comes back again to Regular. So whenever I press “Previous layer”, it only operates between the master and first non-master layer beneath it, but ignores all others.

Just to see how it will behave, I added another master there and brace layer. In that case Previous Layer command goes: Regular > Layer 1 > {500} > Bold > Regular and so forth. Still ignoring other layers. And if I press “Next Layer”, it even ignores the Layer 1.

I was wondering if there is a way to go around that – I would assume that the “Layer” command is there especially for the cases like this, when I want to switch between non-master layers.


The command is supposed to only go to master layers.

I see, but then what is the difference between Edit>Other>Next/Previous Master and Edit>Other>Next/Previous Layer?

The “layer” commands will goto any “special” layer, like color, brace, bracket …

Then wouldn’t it be better to call that command “Next/Previous Master or Special Layer”? I agree that it would be useful to have a command that goes sequentially through layers in the order they are shown in the UI, regardless of whether they are color, brace, master, etc. — there are plenty of situations where this would be better than having to click through them in the UI.

Alternatively, is there a way to do this with a python script (including changing which layer is displayed in the UI)?

You can build a script that select the next layer. But filtering the list is not possible (there are some options in the next version).

direction = 1

editViewController = Font.currentTab
layer = editViewController.activeLayer()
graphicView = editViewController.graphicView()

layers = layer.parent.sortedLayers()
layerIndex = layers.indexOfObject_(layer)
layerIndex += direction
if layerIndex < 0:
	layerIndex = len(layers) - 1
elif layerIndex >= len(layers):
	layerIndex = 0
newLayer = layers[layerIndex]
attributes = {"GSLayerIdAttrib":newLayer.layerId}
selectedRange = graphicView.selectedRange()
if selectedRange.length == 0:
	selectedRange.length = 1

textStorage = graphicView.textStorage()
if NSMaxRange(selectedRange) <= textStorage.text().length():
	textStorage.text().addAttributes_range_(attributes, selectedRange)

Thanks Georg! I tried running that and got this error:

Traceback (most recent call last):
  File "<macro>", line 21, in <module>
NameError: name 'NSMaxRange' is not defined

Add a from Foundation import NSMaxRange at the top of the script.

1 Like

Sorry if my original question was confusing.

I don’t really understand how to show it, will try with gif. In the color font I selected the lowest one (Color 1) and pressed command “Previous Layer”. From Color 1 it skipped middle (Color 0) and switched to the color layer on the top (Color 2) and then switched to Regular. After that it only goes from Regular to Color 2 back and forth.

Now after your reply I wonder if this is some sort of bug? Shouldn’t it switch normally between all “special” layers then? This behaviour occurs in all files for me.

that it would select the “Color 2” was basically a glicht. It is supposed to only switch to “Bold” layers. I fixed it that color layers are Bold now.

Thank you Georg!