Toolbar Toggle/Checkbox Button

Hi,

in my ViewContribution I add a couple of toolbar items via

 registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
 toolbar.registerItem({...});

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

image
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
Wolfgang

@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: https://github.com/eclipse-theia/theia/blob/9a61b776c1e02b8b0d22482a2696e44cd2805333/packages/debug/src/browser/debug-frontend-application-contribution.ts#L1074-L1080

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?

done, https://github.com/eclipse-theia/theia/issues/8312

1 Like