Skip to content

Range

Inherits: Control < CanvasItem < Entity < Object

Inherited by: EditorSpinSlider, ProgressBar, ScrollBar, Slider, SpinBox, TextureProgressBar

Abstract base class for controls that represent a number within a range.

Range is an abstract base class for controls that represent a number within a range, using a configured step and page size. See e.g. ScrollBar and Slider for examples of higher-level nodes using Range.

Type Name Default
bool allow_greater false
bool allow_lesser false
bool exp_edit false
float max_value 100.0
float min_value 0.0
float page 0.0
float ratio
bool rounded false
BitField[Control.SizeFlags] size_flags_vertical 0 (overrides Control)
float step 0.01
float value 0.0
Returns Method
void _value_changed(new_value: float) virtual
void set_value_no_signal(value: float)
void share(with: Entity)
void unshare()

changed

changed()

Emitted when min_value, max_value, page, or step change.

value_changed

value_changed(value: float)

Emitted when value changes. When used on a Slider, this is called continuously while dragging (potentially every frame). If you are performing an expensive operation in a function connected to value_changed, consider using a debouncing Timer to call the function less often.

Note: Unlike signals such as LineEdit.text_changed, value_changed is also emitted when value is set directly via code.

allow_greater

bool allow_greater = false

If true, value may be greater than max_value.

allow_lesser

bool allow_lesser = false

If true, value may be less than min_value.

exp_edit

bool exp_edit = false

If true, and min_value is greater or equal to 0, value will be represented exponentially rather than linearly.

max_value

float max_value = 100.0

Maximum value. Range is clamped if value is greater than max_value.

min_value

float min_value = 0.0

Minimum value. Range is clamped if value is less than min_value.

page

float page = 0.0

Page size. Used mainly for ScrollBar. A ScrollBar’s grabber length is the ScrollBar’s size multiplied by page over the difference between min_value and max_value.

ratio

float ratio

The value mapped between 0 and 1.

rounded

bool rounded = false

If true, value will always be rounded to the nearest integer.

step

float step = 0.01

If greater than 0.0, value will always be rounded to a multiple of this property’s value above min_value. For example, if min_value is 0.1 and step is 0.2, then value is limited to 0.1, 0.3, 0.5, and so on. If rounded is also true, value will first be rounded to a multiple of this property’s value, then rounded to the nearest integer.

value

float value = 0.0

Range’s current value. Changing this property (even via code) will trigger value_changed signal. Use set_value_no_signal() if you want to avoid it.

_value_changed

void _value_changed(new_value: float) virtual

Called when the Range’s value is changed (following the same conditions as value_changed).

set_value_no_signal

void set_value_no_signal(value: float)

Sets the Range’s current value to the specified value, without emitting the value_changed signal.

share

void share(with: Entity)

Binds two Ranges together along with any ranges previously grouped with either of them. When any of range’s member variables change, it will share the new value with all other ranges in its group.

unshare

void unshare()

Stops the Range from sharing its member variables with any other.