How to disable a custom modebar button?

I’ve added my own modebar buttons. I need to control when these buttons are enabled or disabled (visually disabled buttons should display differently than enabled buttons in the modebar) depending the state of my application.

How can I control the enabled/disabled state of modebar buttons?