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
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).
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?)
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.