Any reason why Slider suffix isnt working?

#1

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);
addAndMakeVisible(labelActivation);
ctrlActivation.setTooltip("Tube Curve");
ctrlActivation.setSliderStyle(juce::Slider::SliderStyle::Rotary);
ctrlActivation.setRange(0, 100, 0.1);
ctrlActivation.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20);
ctrlActivation.setNumDecimalPlacesToDisplay(1);
ctrlActivation.setTextValueSuffix("%");
ctrlActivation.setColour(Slider::rotarySliderOutlineColourId, assets->PanelDark);
ctrlActivation.setColour(Slider::textBoxBackgroundColourId, assets->PanelDark);
ctrlActivation.setColour(Slider::textBoxOutlineColourId, assets->PanelDark);
ctrlActivation.setColour(Slider::thumbColourId, assets->Yellow);
ctrlActivation.addListener(this);
addAndMakeVisible(ctrlActivation);

#2

Google: percent escape c++

Rail

#3

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

#4

Then put a breakpoint in Slider::getTextFromValue()

Rail

#5

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

1 Like
#6

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.

#7

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

#8

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

#9

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

#10

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)