Any reason why Slider suffix isnt working?

So I have some controllers l&f v4 on juce 5.4.1 but for some reason setTextValueSuffix isn’t showing in my UI. I have overriden the look and feel. I do have a custom look and feel inherited from V4 but only using it on my own sliders elsewhere?

labelActivation.setText(String("Tube"), juce::NotificationType::dontSendNotification);
ctrlActivation.setTooltip("Tube Curve");
ctrlActivation.setRange(0, 100, 0.1);
ctrlActivation.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
ctrlActivation.setColour(Slider::rotarySliderOutlineColourId, assets->PanelDark);
ctrlActivation.setColour(Slider::textBoxBackgroundColourId, assets->PanelDark);
ctrlActivation.setColour(Slider::textBoxOutlineColourId, assets->PanelDark);
ctrlActivation.setColour(Slider::thumbColourId, assets->Yellow);

Google: percent escape c++


Thanks for replying but it’s not that I have other sliders with db suffix and ms suffix and there not showing either.

Then put a breakpoint in Slider::getTextFromValue()


If I remember correctly, the suffix is ignored once a SliderAttachment is used with the slider.

1 Like

That would explain it. I’ve always managed state myself and found I’ve reinvented ValueTree’s in one form or another so started to do it the juce way for this one.

Is there a workaround to get suffix to work when SliderAttachment is used?

I use my own attachment (inherits from JUCE’s SliderAttachment) to display the valueToText function of the attached parameter:

Maybe you can add your own “addSuffix()” method to the Attachment class

Yeah OK, so do I just need to override the getTextFromValue function and remember
suffix state in the new class?

I don’t think you need to change anything. The Attachment propagates the lambda from the parameter to the slider. You can unset them after you attached it to the parameter to get the original behaviour back:

slider.textFromValueFunction = nullptr;
slider.valueFromTextFunction = nullptr;

(my preference is to have the lambda for consistency though. In case you are not aware, the lambda is used, when the host displays the value, e.g. in it’s automation)