I need to add an operator in the contextual menu of my buttons. I found the way to do something like this here. But it adds operator in the contextual menus of every button and property, and I want to add this for my buttons only. Best I can do is filter it by modifying menu_func method:

def menu_func(self, context):
    if context.region.type == 'TOOLS':
        layout = self.layout

So it's extending the context menus of all buttons and properties in TOOLS panel, not everywhere. How can I filter it more? For example to buttons with same name pattern, or at least to buttons in the panel/category I made.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.