A set of ToggleAction menu items that only one can be in the selected state
Hi. I'm trying to add a set of context menu items that can be checked and unchecked, like this:
But I want them to act like a set of radio buttons, that only one can be checked at a time with the rest to be unchecked. Will ToggleAction work for this purpose?
Please sign in to leave a comment.
Yes, you can store option state somewhere (ex: in PersistentStateComponent) and access it from multiple actions (only one of which would return `isSelected == true`).
As an example, you can look at AnAction in editor gutter menu, that allows to toggle "Breadcrumbs" position.
https://github.com/JetBrains/intellij-community/blob/master/xml/impl/src/com/intellij/xml/breadcrumbs/ToggleBreadcrumbsSettingsAction.java
Thank you. It worked.