I don't want to snap a text input value. But it's forcing me to


#1

Hi, I’ve just noticed this in the juce slider code:

    void labelTextChanged (Label* label) override
    {
        auto newValue = owner.snapValue (owner.getValueFromText (label->getText()), notDragging);
...
}

And can someone tell me how to NOT snap a text inputted value. Do I just delete that snapValue call? It seems to work OK if I do.
What I want is allow the user to change pitch in semi-tones on a slider and to be able to have any value when holding shift, or indeed, input a text number.
Note I can’t override the labelTextChanged function, presumably because of the Pimpl: stuff.


#2

To me it looks like since owner is a Slider, the implementation does nothing:

But you can override it, to actually snap: Slider::snapValue() override

Maybe you can try Slider::getThumbBeingDragged() < 0 to implement snap differently, if the value comes from the textbox…

Good luck…

(P.S. mousewheel could be a caveat…)


#3

Yes, I’ve implemented a skip mechanism for my snap code. Thanks, yeah, there’s a way around it.
What is the reasoning behind snapping an inputted value? Seems a little odd to me.


#4

I think to make the value matching a range, the plugin can use, which is limiting it between min and max, and to adapt for fixed steps, maybe.
But TBH I think most is taken care of by the AudioProcessorParameterXX classes. They might be used outside a AudioProcessor context, so it makes sense for me to keep them usable…