Can't set slider text box outline on Mac

I’m trying to change the outline color of a text box on a slider in an audio plugin project. When I call setColour(Slider::textBoxOutlineColourId, Colours::red); it gives the slider text box a red outline on windows but makes it disappear on mac. Why is this happening? Here’s a minimal example:

#pragma once
#include "../JuceLibraryCode/JuceHeader.h"

constexpr auto PLUGIN_WIDTH = 400;
constexpr auto PLUGIN_HEIGHT = 200;

class MyLookAndFeel final : public LookAndFeel_V4 {
	MyLookAndFeel() : LookAndFeel_V4(getLightColourScheme()) {
		setColour(Slider::textBoxOutlineColourId, Colours::red);

std::unique_ptr<MyLookAndFeel> laf(new MyLookAndFeel());

class MyAudioProcessorEditor final : public AudioProcessorEditor {
	(AudioProcessor& p) : AudioProcessorEditor(&p), processor(p) {
		setResizable(true, true);
	~MyAudioProcessorEditor() = default;
	void paint(Graphics& graphics) override {
	void resized() override {

		auto bounds = Rectangle<int>(PLUGIN_WIDTH, PLUGIN_HEIGHT);


		const auto sliderRect = bounds.removeFromTop(20);

	MyLookAndFeel lookAndFeel;
	AudioProcessor& processor;
	Slider slider1;


class MyAudioProcessor final : public AudioProcessor {
	void processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override { }
	MyAudioProcessor() : AudioProcessor(
		BusesProperties().withInput("Input", AudioChannelSet::stereo(), true).withOutput(
			"Output", AudioChannelSet::stereo(), true)) { }
	~MyAudioProcessor() = default;
	void init(const double sampleRate) { };
	void prepareToPlay(const double sampleRate, const int samplesPerBlock) override { init(sampleRate); }
	void releaseResources() override { }
#ifndef JucePlugin_PreferredChannelConfigurations
	bool isBusesLayoutSupported(const BusesLayout& layouts) const override { return true; }
	AudioProcessorEditor* createEditor() override { return new MyAudioProcessorEditor(*this); }
	bool hasEditor() const override { return true; }
	const String getName() const override { return JucePlugin_Name; }
	bool acceptsMidi() const override { return false; }
	bool producesMidi() const override { return false; }
	bool isMidiEffect() const override { return false; }
	double getTailLengthSeconds() const override { return 0.0; }
	int getNumPrograms() override { return 1; }
	int getCurrentProgram() override { return 0; }
	void setCurrentProgram(int index) override {}
	const String getProgramName(int index) override { return {}; }
	void changeProgramName(int index, const String& newName) override {}
	void getStateInformation(MemoryBlock& destData) override {}
	void setStateInformation(const void* data, const int sizeInBytes) override {}

For what it’s worth, this is also happening with many other colors pertaining to slider text boxes. You can effectively make slider text boxes disappear on mac by setting a bunch of custom colors.

Update: After more experimenting, it seems this doesn’t just happen with slider text box colors, it happens with all colors. Sorry if I sent anybody on wild goose chases looking for something specific to slider text boxes.

However, I found a method of setting those colors that works. Calling the Colour() constructor directly:

		setColour(Slider::textBoxOutlineColourId, Colour(0,0,0));
		setColour(Slider::textBoxTextColourId, Colour(0, 0, 0));
		const auto color = getLightColourScheme().getUIColour(ColourScheme::highlightedFill);
		setColour(Slider::textBoxHighlightColourId, Colour(color.getRed(), color.getGreen(), color.getBlue()));

My problem must have something to do with the alpha channel on the pre-defined colors? Not sure. At any rate, using the Colour() constructor lets me do what I was trying to do so I’m happy.

Different behavior on Mac vs. PC still seems like a bug though. ¯\_(ツ)_/¯

The juce colours and your lookandfeel are globals in different translation units, so their relative initialisation order is unspecified. It sounds like on Windows, the colours are initialised before the LAF, but on Mac the LAF gets initialised before the colours. Consider making your LAF a member of your main editor, so that it is always initialised after all globals.

1 Like