SpinSlider
August 15, 2024

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.

SpinSlider

Usage

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.

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.

Other

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 NameTypeWhat
normalStyleBoxDetermines the background of the control when read_only is false
read_onlyStyleBoxDetermines the background of the control when read_only is true
focusStyleBoxStyle drawn on top of background when the control has input focus
grabberIconDirectly assigned into the grabber theme entry of the internal HSlider
grabber_highlightIconDirectly assigned into the grabber_highlight theme entry of the internal HSlider
up_downIconThe two arrows placed at the right side of the control
font_colorColorColor of the "text"
font_selected_colorColorColor of the "text" when it's selected
font_read_only_colorColorColor of the "text" when read_only is true
font_outline_colorColorOutline color of the "text"
caret_colorColorColor of the caret in the input box
selection_colorColorColor of the selection highlight
slider_colorColorBackground color of the internal slider
slider_ratioColorColor of the ratio indicator when the slider does not have highlight (mouse isn't over it)
slider_read_only_colorColorColor of the slider when read_only is true
fontFontThe font of the "text"
font_sizeInteger (font_size)Size of the font
slider_heightInteger (constant)The height of the internal slider