How to check selection of non-master layers

I want to run a script to multiple selected non-master layers, but GSFont.selectedLayers does not return the list of them. And I don’t know how to check if any given layer is currently selected. Is there a way?

What do you mean by selected? Selected in the layer panel on the right?

Yes. If you select sub layers and run GSFont.selectedLayers, only one master layer is returned.

You need all selected layers in the layer panel?

That is not easily accessible. The ability to select more than one layer is a fairly recent addition. I have to check how to access it.

Thanks, at least it’s nice to confirm it’s not possible yet.

I think you cannot select multiple layers of multiple glyphs (either multiple glyphs in one master or multiple layer in one glyph). Maybe the same GSFont.selectedLayers could return one or the other depending on the situation, or you could add GSGlyph.selectedLayers?

windowController = Font.parent.windowController()
panelSidebar = windowController.panelSidebarViewController()
palettes = panelSidebar.valueForKey_("paletteInstances")
for palette in palettes:
	if palette.__class__.__name__ == "GlyphsPaletteLayers":
layers = palette.allSelectedLayers_(palette.layersList().selectedRowIndexes())