Best way to create a basic LED on or off when button pressed?

Hi there, I am working on my first audio plugin using Juce.

I would like to implement an LED on or off effect based on if a button is pressed or not, similar to what was done here.

Screen Shot 2021-12-22 at 9.31.45 AM

I was wondering what the best way to implement this would be, I assume it would be using a buttonclicked method, but not sure if it would be better done using graphics, or some sort of changing already built images.

If anyone has any advice or code examples it would be greatly appreciated.

Thanks!

button listener triggering the led component to repaint with the button’s toggle state also changing the led’s state. led would just draw a bunch of big transparent red circles and a little opaque one, and apparently a white one for shinyness

1 Like

Or you can make your button bigger and just include the LED as part of the button drawing, and optionally override Component::hitTest to exclude the LED area from the clickable zone.

1 Like