Enablement state of ToolbarButtons


I made a Toolbar with a few buttons that are connected to a CommandID via setCommandToTrigger. Everything works great, however the Buttons are greyed out ( = setEnabled(false) ) whenever the command target is not active ( = the component has not the keyboard focus).

This looks a bit weird as if the buttons would not be working. Is there a workaround or am I doing something horribly wrong?

If I hack Button::applicationCommandListChangeCallback() and deactivate setEnabled(false), all buttons are enabled by default (Twist!), but then again I have a few buttons which are enabled based on certain conditions and they look stupid now.

TLDR: Is there a way to automatically update the enablement state for buttons with inactive ApplicationCommandTarget without having to grant them the KeyboardFocus?


OK, if I use one ApplicationCommandManager per component and a combination of commandStatusChanged() and setFirstCommandTarget(this), it works, but it still feels a bit hacky...