Topic: Context toolbar with toggle button

I use in my custom plugin editor.addContextToolbar to add a toggle button in a context toolbar. I'm allowed set active state of this button in onclick function setActive(). I use the context menu for more than one elements and I have to set currently state of the toggle button, otherwise the toggle button will be shown in last state. How can I set a trigger like onPostRender for this?