Locking state of buttons


#1

I have a set of different buttons, all deriving from juce::Button, all of them has .setClickingTogglesState(true). I would like to have the ability to 'lock' the state of the button, such that after locking it the user can't click or alter the state (which would also mean no callbacks or state changes happen). How would i go about doing this?

 

Case in point, consider having 4 adjacent buttons, where one button has to be clicked (ie. a choice of 4 values). It would be logical not to be able to 'untoggle' the already toggled button, so the user has to select one of the choices.


#2

You could use setEnabled (false) on them?


#3

Thanks, it didn't occur to me that Component has this functionality, was looking the wrong place! 


#4

Isn't this a radio group? Have you looked at the JUCE demo "Components: Tabs and Widgets" -> "Buttons" page? This has a radio group of 4 mutually exclusive toggle buttons.