Contextual Menu and Palette Plugin?

Is it possible to add a contextual menu for a Palette plugin?
After several attempts, it seems to work only for SelectTool and ReporterPlugin.

Implement

+ (void)contextMenuCallback:(NSMenu *)menu forSelectedLayers:(NSArray *)layers event:(NSEvent *)event;

or in python:

@classmethod
@objc.signature('v@:@@@')
def contextMenuCallback_forSelectedLayers_event_(cls, menu, layers, event):

Then add a callback (make sure to call this only once, so not for each palette):

[GSCallbackHandler addCallback:self.class forOperation:GSContextMenuCallbackName];

or in python:

GSCallbackHandler.addCallback_forOperation_(self.__class__, GSContextMenuCallbackName)
1 Like