Change color when slider is used

Is there a way to change the stock slider in juce so that it changes slider fill color when used? Thanks!

1 Like

You can use the sliders methods (mouse down, on enter, on exit, mouse up, on value change, there are a ton of potential trigger points for a component, pick which one makes sense for your use case), in that given function you could update the colour in the look and feel.

do i have to have the slider as a separate component to do it?
thank you

You should be able to use the onDragStart and onDragEnd lambdas to do what you want. Change the colour in one, change it back in the other. No need to make custom components from what I can tell.


Thanks for the help!
i was able to make it work with getThumbBeingDragged but i cant find the way to do it for all of my sliders, its just lets me make them one at a time.

if (juce::Slider; driveKnob->getThumbBeingDragged())

    getLookAndFeel().setColour(juce::Slider::rotarySliderFillColourId, juce::Colours::orangered);

    getLookAndFeel().setColour(juce::Slider::rotarySliderFillColourId, juce::Colours::blue);

this code works but when i try to add all the sliders, only the last one is working.

Just a thought, but you could do it in a custom look and feel class. In the drawSlider methods, you get a reference to the slider, so you could do that slider-> getThumbBeingDragged check there, which would be checking whichever slider is currently being drawn. Checkout LookAndFeel_v4 etc in the juce code to see how some of the methods work.

If you move one slider, only this one is repainting.
You would need to notify all sliders in your plugin to repaint when a single on moves.

finally getting some form of what i was looking for, with a little bit of work it will be what i wanted thank you very much!