I want to make a toggle button for my custom operator. It works similar to checkbox: once the button is clicked, the operator keeps running until the button gets another click, so will the button itself greyed out. I tried to achieve the grey-out effect by implementing poll() function like this:
@classmethod def poll(cls, context): return context.area.type == 'VIEW_3D' and context.region.type == 'WINDOW' and plane_toggle_flag
Every time the button is clicked I want the toggle state to change, so in the operator's init(), I write:
def __init__(self): plane_toggle_flag=not plane_toggle_flag
However, it seems as long as poll() returns false, the init() function never get the chance to be called. Any idea how to solve this? Thank you in advance.