How to know if a slider value is final

Hi,

I’ve got a derived class of juce::Slider.
I need to send the value of the slider to a different class,
but only if it’s a final value.
Eg, I don’t want the slider to keep sending values to the class while it’s being dragged,
only when the user has finished dragging the slider and has the required value.

Eg, when using the valueChanged() method of the slider class, you get dozens of valueChanged() triggered as you slide the slider. As this is for an undo/redo system, that won’t work.

So, I thought I would simply override the mouseUp method in my slider class, like this:

void mouseUp(const juce::MouseEvent& event) override
{
	GetRootManager()->GetChangeManager()->
					ModuleWidgetSetFloatValue((ModuleWidget*) floatSliderModuleWidget, 
					"value", getValue(), true);
	repaint();
}

And this works, but, with this solution, whenever the user manually types in a value in the slider’s textbox, it won’t be registered and the final value entered as text won’t be sent to my class,
as it’s a mouseUp event only…

Does anyone know of a solution to this ?

Thanks, it’s really appreciated!,
Terrence

PS: A simple solution would suffice, I can’t really start reimplementing my 120+ files of C++ code at this time with a fancy and complex listener system…

Hi,
see Slider::setChangeNotificationOnlyOnRelease(bool onlyNotifyOnRelease)
https://docs.juce.com/master/classSlider.html#ab41e52ab8941619028a8d57103975029

2 Likes

Hi jcomusic,

Thanks a lot! I don’t know why I missed it in the documentation,
but it definately did the trick! :slight_smile:

Big Thanks :slight_smile:
Cheers!,
Terrence

1 Like