From 52079652d06310003e7b4e877eb9304049c3b298 Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Fri, 27 Jun 2025 16:02:14 +0100 Subject: [PATCH] Slider: Update docs regarding conversions between values and text --- modules/juce_gui_basics/widgets/juce_Slider.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_Slider.h b/modules/juce_gui_basics/widgets/juce_Slider.h index 57aab5fd64..0a720a3ede 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/modules/juce_gui_basics/widgets/juce_Slider.h @@ -622,10 +622,10 @@ public: /** You can assign a lambda to this callback object to have it called when the slider's drag ends. */ std::function onDragEnd; - /** You can assign a lambda that will be used to convert textual values to the slider's normalised position. */ + /** You can assign a lambda that will be used to convert text to a slider value. */ std::function valueFromTextFunction; - /** You can assign a lambda that will be used to convert the slider's normalised position to a textual value. */ + /** You can assign a lambda that will be used to convert a slider value to text. */ std::function textFromValueFunction; //============================================================================== @@ -746,25 +746,29 @@ public: virtual void valueChanged(); //============================================================================== - /** Subclasses can override this to convert a text string to a value. + /** Returns a slider value for some given text. + + Subclasses can override this to convert a text string to a value. + Alternatively assign a lambda to valueFromTextFunction. When the user enters something into the text-entry box, this method is called to convert it to a value. The default implementation just tries to convert it to a double. - @see getTextFromValue + @see getTextFromValue, valueFromTextFunction, textFromValueFunction */ virtual double getValueFromText (const String& text); - /** Turns the slider's current value into a text string. + /** Returns a text representation for a given slider value. Subclasses can override this to customise the formatting of the text-entry box. + Alternatively assign a lambda to textFromValueFunction. The default implementation just turns the value into a string, using a number of decimal places based on the range interval. If a suffix string has been set using setTextValueSuffix(), this will be appended to the text. - @see getValueFromText + @see getValueFromText, textFromValueFunction, valueFromTextFunction */ virtual String getTextFromValue (double value);