Create custom toggle button


is there a simple and recommended way for customizing toggle buttons? I simply need it to display some custom image for the enabled/disabled ticks.


You have to create a lookAndFeel which overrides the paint methods you want to customise, and apply this lnf and to your component. You can have a look at the “Look And Feel” demo tab in the Juce Demo for an example.

for customizing toggle buttons

if you’re talking about ToggleButtons, what you want to override is drawTickBox(), and perhaps also drawToggleButton() (for the toggle text).
If you are not interested in ToggleButton, but in an other type of buttons that you have setClickingTogglesState (true), then you have to override something else. perhaps drawButtonBackground(). You can find it out by looking at what is called in your button’s paint() routine.

to draw images, you can use Graphics::drawImage()

That’s what I feared…

Thanks :slight_smile:


well, you can still create a button class that inherits button and just overrides paintButton() if that suits you better. Using ImageButton may also be an option perhaps.