I have some trouble with setting up a toggle ToolbarButton inside a Toolbar.
I have successfully set-up a toolbar with various icons. The ToolbarItemFactory creates the ToolbarItemComponents, the commands are well triggered either via keyboard short-cuts or by clicking on the icons.
Now I want to add a toggle ToolbarButton. I simply use the other constructor of the ToolbarButton, giving two images instead of one.
Whenever I receive the related command, I manually switch the toggle state via the ToolbarItemComponent.setToggleState method to make it show the right image. Well, nothing happens. It stays on the “off” state.
Via the debugger, I can see that the “lastToggleState” is well set to true in the setToggleState method, a repaint is called, but if I click again on my icon, the “lastToggleState” is still set to false.
What am I doing wrong?
Second strange thing, is it normal that the only way to get a reference on the ToolbarButton is via the Toolbar.getItemComponent(index) method? Is there no way to make a search with the ID? I know it is probably because there can be several instances of the icon, but it seems rather fragile to use an index.