This control offers interaction very similar to the SpinBox ( documentation here ). Or in other words, it offers a input box to enter numerical values. Yet, if both minimum and maximum values are desired to be enforced, then this widget will display a slider allowing to set the value through interaction with it.
In the screenshot bellow two instances of the SpinSlider are shown. The bottom one has been setup to enforce both minimum and maximum values to 0 and 100. As a result the slider appears bellow it.
Usage of this control is very similar to the SpinBox. Selecting an instance of the SpinSlider shows the following properties in the inspector:
Bellow are these properties with some explanation.
alignmentallow_math_expressionread_onlyeditable=false in the LineEdit or the SpinBox.update_on_text_changedallow_math_expression = true.prefixsuffixsteprounded_valuesselect_all_on_focusno_spin_with_sliderrange is setup.assign_minmax_on_right_clickuse_min_value and/or use_max_value is/are disabled.range_use_min_valueSpinSlider will enforce a minimum value.range_min_valuerange_use_min_value is true. When that's the case, attempting to input anything bellow the specified will assign range_min_value instead.range_use_max_valueSpinSlider will enforce a maximum value.range_max_valuerange_use_max_value is true. When that's the case, attempting to input anything above the specified will assign range_ma_value instead.Dealing with the SpinSlider through code is normally done by simply directly reading or assigning the various properties that are shown above. Yet, there are three functions that I want to mention.
The first one is get_line_edit(). This function returns a reference to the internal LineEdit used for the input. Please, do not delete it otherwise the SpinSlider will fail, most likely resulting in a crash! Obtaining this control is useful when you want to listen to some of the LineEdit events or maybe disable its context menu.
Then there are get_as_ratio() and set_as_ratio(). Those two functions only have meaning if the range_use_min_value and range_use_max_value properties are enabled. When that's the case it provides means to deal with the values through percent values instead, in the range [0..1].
The SpinSlider emits only two signals. The value_changed is emitted when the assigned value is changed. And the value_entered is emitted whenever the internal LineEdit emits text_submitted(). The parameter of this second signal contains the raw string, so possibly not a full numerical value.
The table bellow lists all available theming options for the SpinSlider widget. Remember, overriding any of those is easily done through the Inspector. Creating a Theme resource to customize these elements require manually adding the desired entries within the theme editor. Please refer to the introduction for more information on how to customize the widgets using a Theme resource.
| Style Name | Type | What |
|---|---|---|
normal | StyleBox | Determines the background of the control when read_only is false |
read_only | StyleBox | Determines the background of the control when read_only is true |
focus | StyleBox | Style drawn on top of background when the control has input focus |
grabber | Icon | Directly assigned into the grabber theme entry of the internal HSlider |
grabber_highlight | Icon | Directly assigned into the grabber_highlight theme entry of the internal HSlider |
up_down | Icon | The two arrows placed at the right side of the control |
font_color | Color | Color of the "text" |
font_selected_color | Color | Color of the "text" when it's selected |
font_read_only_color | Color | Color of the "text" when read_only is true |
font_outline_color | Color | Outline color of the "text" |
caret_color | Color | Color of the caret in the input box |
selection_color | Color | Color of the selection highlight |
slider_color | Color | Background color of the internal slider |
slider_ratio | Color | Color of the ratio indicator when the slider does not have highlight (mouse isn't over it) |
slider_read_only_color | Color | Color of the slider when read_only is true |
font | Font | The font of the "text" |
font_size | Integer (font_size) | Size of the font |
slider_height | Integer (constant) | The height of the internal slider |