XU XUv0.13.1
中文

UI / WIDGETS / Selection

RangeSlider

Choose a range using two endpoints

Run the Xu example

The example executes in the browser using the Xu/WASM runtime.

What to try

Adjust the lower and upper bounds.

Usage notes

Two endpoints define the range. Specify bounds and how crossings are handled and make both endpoints keyboard adjustable.

Create through Screen

The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.

Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.

#ui/widgets

fn configure(screen $&widgets.Screen) int {
    id := screen.range_slider(0.0,100.0,20.0,80.0) or >>
    screen.place(id,24.0,24.0,320.0,80.0) or >>
    << id
}

($&Screen) range_slider

XuAPI
pub fn (s $&Screen) range_slider(minimum f64,maximum f64,lower f64,upper f64) int

Purpose

Create RangeSlider in Screen and return the component node ID; throw on creation failure.

Parameters

s $&Screen
The Screen instance used by this call (exclusive borrow).
minimum f64
minimum (f64)
maximum f64
maximum (f64)
lower f64
lower (f64)
upper f64
upper (f64)

Returns

int — component node ID for place and other Screen methods.

Placement, state and events

The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.

Action · Styles · UI lifecycle and styling guide

Screen.place · Screen.set_enabled · Screen.set_visible

Standalone control object API

These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.

struct RangeSlider

XuAPI
pub struct RangeSlider {

}

Purpose

RangeSlider context or state structure.

Public fields

This type has no public fields.

(&RangeSlider) id

XuAPI
pub fn (r &RangeSlider) id() int

Purpose

Return the unique integer ID of the element or control.

Parameters

r &RangeSlider
The RangeSlider instance used by this call (borrow).

Returns

int — a value of this type

(&RangeSlider) bounds

XuAPI
pub fn (r &RangeSlider) bounds() layout.Rect

Purpose

Return the bounding Rectangle of the control or geometry.

Parameters

r &RangeSlider
The RangeSlider instance used by this call (borrow).

Returns

layout.Rect — a value of this type

(&RangeSlider) values

XuAPI
pub fn (r &RangeSlider) values() RangeValues

Purpose

Return a slice containing all values in the collection.

Parameters

r &RangeSlider
The RangeSlider instance used by this call (borrow).

Returns

RangeValues — a value of this type

(&RangeSlider) needs_paint

XuAPI
pub fn (r &RangeSlider) needs_paint() bool

Purpose

Return whether the control needs repainting; call painted after painting to clear the flag.

Parameters

r &RangeSlider
The RangeSlider instance used by this call (borrow).

Returns

bool — true or false

($&RangeSlider) painted

XuAPI
pub fn (r $&RangeSlider) painted()

Purpose

Acknowledge the painted frame and clear the dirty flag; this is not a query.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).

Returns

This call does not return a value.

(&RangeSlider) is_enabled

XuAPI
pub fn (r &RangeSlider) is_enabled() bool

Purpose

Return whether the control is currently enabled.

Parameters

r &RangeSlider
The RangeSlider instance used by this call (borrow).

Returns

bool — true or false

(&RangeSlider) style_or

XuAPI
pub fn (r &RangeSlider) style_or(styles &Styles) ControlStyle

Purpose

Operation on &RangeSlider: style or.

Parameters

r &RangeSlider
The RangeSlider instance used by this call (borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

ControlStyle — a value of this type

($&RangeSlider) set_values

XuAPI
pub fn (r $&RangeSlider) set_values(lower f64,upper f64) int

Purpose

Operation on $&RangeSlider: set values. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
lower f64
lower (f64)
upper f64
upper (f64)

Returns

int — a value of this type

($&RangeSlider) set_options

XuAPI
pub fn (r $&RangeSlider) set_options(o &RangeSliderOptions) int

Purpose

Operation on $&RangeSlider: set options. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
o &RangeSliderOptions
o (read-only borrow; caller keeps the original; type &RangeSliderOptions)

Returns

int — a value of this type

($&RangeSlider) set_appearance

XuAPI
pub fn (r $&RangeSlider) set_appearance(a &SliderAppearance) int

Purpose

Operation on $&RangeSlider: set appearance. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
a &SliderAppearance
value (read-only borrow; caller keeps the original; type &SliderAppearance)

Returns

int — a value of this type

($&RangeSlider) set_locale

XuAPI
pub fn (r $&RangeSlider) set_locale(locale &Locale) int

Purpose

Operation on $&RangeSlider: set locale. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
locale &Locale
locale (read-only borrow; caller keeps the original; type &Locale)

Returns

int — a value of this type

($&RangeSlider) set_style

XuAPI
pub fn (r $&RangeSlider) set_style(style &ControlStyle) int

Purpose

Operation on $&RangeSlider: set style. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
style &ControlStyle
style (read-only borrow; caller keeps the original; type &ControlStyle)

Returns

int — a value of this type

($&RangeSlider) clear_style

XuAPI
pub fn (r $&RangeSlider) clear_style()

Purpose

Operation on $&RangeSlider: clear style.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&RangeSlider) set_motion

XuAPI
pub fn (r $&RangeSlider) set_motion(spec &MotionSpec) int

Purpose

Operation on $&RangeSlider: set motion. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
spec &MotionSpec
spec (read-only borrow; caller keeps the original; type &MotionSpec)

Returns

int — a value of this type

($&RangeSlider) cancel

XuAPI
pub fn (r $&RangeSlider) cancel()

Purpose

Execute cancel on $&RangeSlider.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&RangeSlider) set_focus

XuAPI
pub fn (r $&RangeSlider) set_focus(value bool)

Purpose

Operation on $&RangeSlider: set focus.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
value bool
value (bool)

Returns

This call does not return a value.

($&RangeSlider) set_enabled

XuAPI
pub fn (r $&RangeSlider) set_enabled(value bool)

Purpose

Operation on $&RangeSlider: set enabled.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
value bool
value (bool)

Returns

This call does not return a value.

($&RangeSlider) set_read_only

XuAPI
pub fn (r $&RangeSlider) set_read_only(value bool)

Purpose

Operation on $&RangeSlider: set read only.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
value bool
value (bool)

Returns

This call does not return a value.

($&RangeSlider) set_bounds

XuAPI
pub fn (r $&RangeSlider) set_bounds(b &layout.Rect) int

Purpose

Operation on $&RangeSlider: set bounds. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
b &layout.Rect
b (read-only borrow; caller keeps the original; type &layout.Rect)

Returns

int — a value of this type

($&RangeSlider) dispose

XuAPI
pub fn (r $&RangeSlider) dispose()

Purpose

Release and dispose native resources and underlying handles.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&RangeSlider) tab

XuAPI
pub fn (r $&RangeSlider) tab(backward bool,entering bool) bool

Purpose

A RangeSlider has two Tab stops. Screen calls this before moving to another node.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
backward bool
backward (bool)
entering bool
entering (bool)

Returns

bool — true or false

($&RangeSlider) input

XuAPI
pub fn (r $&RangeSlider) input(event &ui.InputEvent) Action

Purpose

Process routed mouse, keyboard, or touch input events.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
event &ui.InputEvent
event (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&RangeSlider) route

XuAPI
pub fn (r $&RangeSlider) route(kind int,event &ui.InputEvent) Action

Purpose

Route and dispatch the input event to matching targets. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
kind int
kind tag (int)
event &ui.InputEvent
event (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&RangeSlider) apply_styles

XuAPI
pub fn (r $&RangeSlider) apply_styles(styles &Styles) int

Purpose

Resolve and apply theme metrics to the control.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

($&RangeSlider) tick

XuAPI
pub fn (r $&RangeSlider) tick(styles &Styles,now time.Instant,reduced bool) bool

Purpose

Advance animation clock and state transition step. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)
now time.Instant
now (time.Instant)
reduced bool
reduced (bool)

Returns

bool — true or false

(&RangeSlider) next_tick

XuAPI
pub fn (r &RangeSlider) next_tick(now time.Instant) time.Instant

Purpose

Operation on &RangeSlider: next tick. Throws on failure; handle the error or propagate it to the caller.

Parameters

r &RangeSlider
The RangeSlider instance used by this call (borrow).
now time.Instant
now (time.Instant)

Returns

time.Instant — a value of this type

($&RangeSlider) paint_styled

XuAPI
pub fn (r $&RangeSlider) paint_styled(frame $&draw.Frame,styles &Styles) int

Purpose

Operation on $&RangeSlider: paint styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&RangeSlider
The RangeSlider instance used by this call (exclusive borrow).
frame $&draw.Frame
frame (exclusive borrow; may modify the original; type $&draw.Frame)
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

Complete native example

Component Workshop · Back to Widgets