What is activeLayer?

It seems I check active layers reliably. When I run the test code below, I get True for way more than one layer. Is it happening to other people too? Or am I misunderstanding the meaning of active layer?

f = Glyphs.font
print(‘Active layer:’, f.currentTab.activeLayer())
for l in f.currentTab.layers:
print( l.parent.name, l == f.currentTab.activeLayer(), l == f.selectedLayers[0])

Returns stuffs like :
Active layer: <GSLayer 0x1450fd6b0> Regular (c)
A True True
k True True
a True True
y True True
c True True
N True True

It’s best to not use == for objects like layers. Instead, check with is:

f = Glyphs.font
print('Active layer:', f.currentTab.activeLayer())
for l in f.currentTab.layers:
	print(l.parent.name, l is f.currentTab.activeLayer(), l is f.selectedLayers[0])

prints:

Active layer: <GSLayer 0x125392820> Regular (C)
A False False
B False False
C True True
D False False
E False False

Ah I see. Thanks!

Another issue; even when using is, the multiple occurrences of the same layer is all reported as True. I’m developing a tool plugin, and things seem to stop working as soon as I have a particular letter multiple times (it works fine for other layers in the same tab).

Why do you need this? What are you trying to do?

I don’t need/want to deal with this; it’s just that simple things like selecting and dragging is not happening when there are multiple of the same layer. (It seems selection seems to be working internally, as indicated in the info box, but there’s no visual feedback; it seems layer coordinates are wrong?)

That should not matter. Again, what are you trying to do?

Select my custom node-like objects, drag them, nothing special.

Are you trying to do that on all visible layers? Otherwise just get the active layer and use that.

No, I want to make it work on the active layer. I’m struggling because Glyphs tells me there are multiple active layers (it seems to be failing on the drawing part).

The “tab.activeLayer” gives you the currently active layer. Just use it. If you need to compare it to other layers, you are in the wrong place. Can you point me to the code and I have a look.