Each component that supports simple color changes has its own set of ColourIds, Slider has the following and you need to access them from the Slider’s namespace with Slider::ColourIds (TextButton::ColourIds applies just to TextButtons) :
enum ColourIds
{
backgroundColourId = 0x1001200, /**< A colour to use to fill the slider's background. */
thumbColourId = 0x1001300, /**< The colour to draw the thumb with. It's up to the look
and feel class how this is used. */
trackColourId = 0x1001310, /**< The colour to draw the groove that the thumb moves along. */
rotarySliderFillColourId = 0x1001311, /**< For rotary sliders, this colour fills the outer curve. */
rotarySliderOutlineColourId = 0x1001312, /**< For rotary sliders, this colour is used to draw the outer curve's outline. */
textBoxTextColourId = 0x1001400, /**< The colour for the text in the text-editor box used for editing the value. */
textBoxBackgroundColourId = 0x1001500, /**< The background colour for the text-editor box. */
textBoxHighlightColourId = 0x1001600, /**< The text highlight colour for the text-editor box. */
textBoxOutlineColourId = 0x1001700 /**< The colour to use for a border around the text-editor box. */
};
Thank you very much, and now I suddenly remembered why I used “TextButton” because, unless I am using the wrong syntax, none of the color ID’s will change colors of Inc/Dec “sliders”;
setColour is a method of Component, so no need for the dynamic_cast.
Check with a breakpoint, if the setColour is actually hit.
A good explanation, how colours work is in findColour()
Looks for a colour that has been registered with the given colour ID number.
If a colour has been set for this ID number using setColour(), then it is returned. If none has been set, the method will try calling the component's LookAndFeel class's findColour() method. If none has been registered with the look-and-feel either, it will just return black.
The colour IDs for various purposes are stored as enums in the components that they are relevant to - for an example, see Slider::ColourIds, Label::ColourIds, TextEditor::ColourIds, TreeView::ColourIds, etc.
That is the method that is called inside the LookAndFeel to find the colour to use
[quote=“daniel, post:6, topic:35517, full:true”]
setColour is a method of Component, so no need for the dynamic_cast.[/quote]
But you might want to ensure you are calling the method only on TextButton instances. (Maybe Slider will never have any other kind of child components, though…)
The lookAndFeel is free to return any kind of Button* in Button* LookAndFeel::createSliderButton (Slider&, const bool isIncrement), and in case of LookAndFeel_V1 it is an ArrowButton, so this might be the reason, why it didn’t work with the dynamic_cast:
I forgot to mention I tested my code above with whatever look and feel is default for Juce 5. In that the inc/dec button slider is just 2 text buttons with “+” and “-” on them.