On / Off switch

Hi all.
I’m looking to create a sliding on/off switch.
I think the best way is with an ImageButton… right?
I see that I could make a slider that would do it fairly painlessly, but if I want the button to toggle every time it is pressed, and not just when it’s pressed on one side or the other, I believe a slider won’t do that.
…right?
Thank you.
ZnJvbT1jc2RuJnVybD1uQm5hdU1YWm9OR2RwZDNjdFVHYm5kMmIwMVNaMnhXWjNSWEx5RXpMekF6THpFRE15OHlja0YyYnNCWGR2UW5ibFJuYnZOV0x3ZDNMdDkyWXU0R1oxbG1icEZuTGpSMmNwVjNMdm9EYzBSSGE

why not a checkbox?
if(myCheckBox){ // = fx processing } else{ // = do nothing }

toggle button is basically a checkbox juce::ToggleButton too.

using your checkbox you can preferably draw using Graphics you sliding button or have 1 image for on and one for off. If checkBox = true then you just have image[0] but if false you have image[1]

That sounds like an idea, but it’s not very clear to me from the documentation how to change a ToggleButton with an image or graphics. I will keep reading, thanks!

Hmm, no. I’m completely lost.

I’ve made a while ago similar button with animation.
Not perfect or production ready but might be helpful for you to look I guess…

2 Likes