Range

Inherits: Control < CanvasItem < Node < Object

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

Abstract base class for range-based controls.

Description

Range is a base class for Control nodes that change a floating-point value between a min_value and max_value, using a configured step and page size. See e.g. ScrollBar and Slider for examples of higher level nodes using Range.

Properties

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

SizeFlags

size_flags_vertical

0 (overrides Control)

float

step

0.01

float

value

0.0

Methods

void

_value_changed ( float new_value ) virtual

void

set_value_no_signal ( float value )

void

share ( Node with )

void

unshare ( )


Signals

changed ( )

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


value_changed ( float value )

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.


Property Descriptions

bool allow_greater = false

  • void set_allow_greater ( bool value )

  • bool is_greater_allowed ( )

If true, value may be greater than max_value.


bool allow_lesser = false

  • void set_allow_lesser ( bool value )

  • bool is_lesser_allowed ( )

If true, value may be less than min_value.


bool exp_edit = false

  • void set_exp_ratio ( bool value )

  • bool is_ratio_exp ( )

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


float max_value = 100.0

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


float min_value = 0.0

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


float page = 0.0

  • void set_page ( float value )

  • float get_page ( )

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


float ratio

  • void set_as_ratio ( float value )

  • float get_as_ratio ( )

The value mapped between 0 and 1.


bool rounded = false

  • void set_use_rounded_values ( bool value )

  • bool is_using_rounded_values ( )

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


float step = 0.01

  • void set_step ( float value )

  • float get_step ( )

If greater than 0, value will always be rounded to a multiple of step. If rounded is also true, value will first be rounded to a multiple of step then rounded to the nearest integer.


float value = 0.0

  • void set_value ( float value )

  • float get_value ( )

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.


Method Descriptions

void _value_changed ( float new_value ) virtual

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


void set_value_no_signal ( float value )

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


void share ( Node with )

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.


void unshare ( )

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