Toolbar Toggle/Checkbox Button


in my ViewContribution I add a couple of toolbar items via

 registerToolbarItems(toolbar: TabBarToolbarRegistry): void {

Does anyone know how to give this items a toggle or checkbox behavior? There’s already something similar implemented for the search options:

Unfortunately the isToggled-property in the registerCommand-Handler seems to do something different:

registerCommands(commands: CommandRegistry): void {
        commands.registerCommand(UrdfIdeCommand, {
            isToggled ? ??

Thanks for your help

@javahacks you can make use of isEnabled (toggle between enabling/disabling) the toolbar item to mimic the behavior of a checkbox or a toggle behavior. Would this be appropriate for your use case?

@vince-fugnitto Thanks for your reply! The problem I see is that once the toolbar item is pressed and the command state is disabled, I no longer can re-press the button to switch back in enabled state? My use case is linking the current symbol selection in the active text editor with my graphical outline view. In Eclipse/IntelliJ there is something like an ‘Link with Editor’ option in the navigator view that uses a toggle button. That’s exactly what I’m trying to reimplement btw.

It sounds like a missing API. We have some toggling like behaviour for activating/deactivating all breakpoints:

Maybe it would be sufficient if the toolbar items would just consider the isToggled() value of registered commands?

registerCommands(commands: CommandRegistry): void {
        commands.registerCommand(UrdfIdeCommand, {
            isVisible,isEnabled, isToggled ? ??

sounds good, could you file a feature request?


1 Like