Accessing active layer from Palette plugin

Working in objC, I’m trying to find the active layer for a palette plugin. I’m not positive which class to access it through, though.

It seems like rather than accessing it through the editViewController, I should be using the activeLayer method from windowController in GSWindowControllerProtocol.h, via GlyphsPaletteProtocol.h. I can’t seem to make that work, though. As the code is below, windowController is null. Does it need to be more explicitly imported?

Here’s the relevant code if that’s helpful:

The windowController is not set when the object in instantiated. You need to add a callback to be notified if something has changed. you can do that like this in -(id)init:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(update:) name:@"GSUpdateInterface" object:nil];

Then you implement:

- (void)update:(id)sender {
    layer = [windowController activeLayer];
1 Like