UI / WIDGETS / Selection
Stepper
Increase or decrease a value by a fixed step
Run the Xu example ↗The example executes in the browser using the Xu/WASM runtime.
What to try
Adjust a quantity and try its limits.
Usage notes
Use for small, discrete quantities. Set minimum, maximum and step values and make the limit state clear.
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.stepper(0.0,100.0,5.0,40.0) or >>
screen.place(id,24.0,24.0,320.0,80.0) or >>
<< id
}
($&Screen) stepper
pub fn (s $&Screen) stepper(minimum f64,maximum f64,step f64,value f64) int
Purpose
Create Stepper 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)
step f64- step (f64)
value f64- value (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.
(&Stepper) clone
pub fn (value &Stepper) clone() Stepper
Purpose
Copy the control or style snapshot into an independent Stepper value.
Parameters
value &Stepper- The
Stepper instance used by this call (borrow).
Returns
Stepper — a value of this type
($&Stepper) set_locale
pub fn (stepper $&Stepper) set_locale(locale &Locale) int
Purpose
Operation on $&Stepper: set locale. Throws on failure; handle the error or propagate it to the caller.
Parameters
stepper $&Stepper- The
Stepper 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
(&Stepper) value_text
pub fn (stepper &Stepper) value_text() string
Purpose
Operation on &Stepper: value text. Throws on failure; handle the error or propagate it to the caller.
Parameters
stepper &Stepper- The
Stepper instance used by this call (borrow).
Returns
string — result string
struct Stepper
Purpose
Stepper context or state structure.
Public fields
This type has no public fields.
See usage example
(&Stepper) id
pub fn (st &Stepper) id() int
Purpose
Return the unique integer ID of the element or control.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
int — a value of this type
(&Stepper) is_selectable
pub fn (st &Stepper) is_selectable() bool
Purpose
Operation on &Stepper: whether it is selectable.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
($&Stepper) set_selectable
pub fn (st $&Stepper) set_selectable(selectable bool)
Purpose
Operation on $&Stepper: set selectable.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
selectable bool- selectable (bool)
Returns
This call does not return a value.
(&Stepper) bounds
pub fn (st &Stepper) bounds() layout.Rect
Purpose
Return the bounding Rectangle of the control or geometry.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
layout.Rect — a value of this type
(&Stepper) value
pub fn (st &Stepper) value() f64
Purpose
Execute value on &Stepper.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
f64 — a value of this type
(&Stepper) min
pub fn (st &Stepper) min() f64
Purpose
Operation on &Stepper: return the smaller of two numeric values.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
f64 — a value of this type
(&Stepper) max
pub fn (st &Stepper) max() f64
Purpose
Operation on &Stepper: return the larger of two numeric values.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
f64 — a value of this type
(&Stepper) step
pub fn (st &Stepper) step() f64
Purpose
Execute step on &Stepper.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
f64 — a value of this type
(&Stepper) can_decrement
pub fn (st &Stepper) can_decrement() bool
Purpose
Operation on &Stepper: can decrement.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
(&Stepper) can_increment
pub fn (st &Stepper) can_increment() bool
Purpose
Operation on &Stepper: can increment.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
(&Stepper) needs_paint
pub fn (st &Stepper) needs_paint() bool
Purpose
Return whether the control needs repainting; call painted after painting to clear the flag.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
($&Stepper) painted
pub fn (st $&Stepper) painted()
Purpose
Acknowledge the painted frame and clear the dirty flag; this is not a query.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
Returns
This call does not return a value.
($&Stepper) invalidate
pub fn (st $&Stepper) invalidate()
Purpose
Invalidate the control area, requesting a repaint on next frame.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
Returns
This call does not return a value.
($&Stepper) cancel
pub fn (st $&Stepper) cancel()
Purpose
Execute cancel on $&Stepper.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&Stepper) is_enabled
pub fn (st &Stepper) is_enabled() bool
Purpose
Return whether the control is currently enabled.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
($&Stepper) set_enabled
pub fn (st $&Stepper) set_enabled(enabled bool)
Purpose
Operation on $&Stepper: set enabled.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
(&Stepper) is_focused
pub fn (st &Stepper) is_focused() bool
Purpose
Return whether the control currently has input focus.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
($&Stepper) set_focus
pub fn (st $&Stepper) set_focus(focused bool)
Purpose
Operation on $&Stepper: set focus.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
focused bool- focused (bool)
Returns
This call does not return a value.
(&Stepper) is_hovered
pub fn (st &Stepper) is_hovered() bool
Purpose
Operation on &Stepper: whether it is hovered.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
(&Stepper) is_invalid
pub fn (st &Stepper) is_invalid() bool
Purpose
Operation on &Stepper: whether it is invalid.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
($&Stepper) set_invalid
pub fn (st $&Stepper) set_invalid(invalid bool)
Purpose
Operation on $&Stepper: set invalid.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
invalid bool- invalid (bool)
Returns
This call does not return a value.
(&Stepper) is_read_only
pub fn (st &Stepper) is_read_only() bool
Purpose
Operation on &Stepper: whether it is read only.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
($&Stepper) set_read_only
pub fn (st $&Stepper) set_read_only(read_only bool)
Purpose
Operation on $&Stepper: set read only.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
read_only bool- read_only (bool)
Returns
This call does not return a value.
($&Stepper) set_value
pub fn (st $&Stepper) set_value(value f64) int
Purpose
Operation on $&Stepper: set value. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
value f64- value (f64)
Returns
int — a value of this type
($&Stepper) set_range
pub fn (st $&Stepper) set_range(min f64,max f64,step f64) int
Purpose
Operation on $&Stepper: set range. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
min f64- minimum (f64)
max f64- maximum (f64)
step f64- step (f64)
Returns
int — a value of this type
($&Stepper) set_bounds
pub fn (st $&Stepper) set_bounds(bounds &layout.Rect) int
Purpose
Operation on $&Stepper: set bounds. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
bounds &layout.Rect- bounds (read-only borrow; caller keeps the original; type &layout.Rect)
Returns
int — a value of this type
(&Stepper) visual_state
pub fn (st &Stepper) visual_state() int
Purpose
Operation on &Stepper: visual state.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
int — a value of this type
(&Stepper) has_style
pub fn (st &Stepper) has_style() bool
Purpose
Operation on &Stepper: whether it has style.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
Returns
bool — true or false
(&Stepper) style_or
pub fn (st &Stepper) style_or(styles &Styles) ControlStyle
Purpose
Operation on &Stepper: style or.
Parameters
st &Stepper- The
Stepper 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
($&Stepper) set_style
pub fn (st $&Stepper) set_style(style &ControlStyle) int
Purpose
Operation on $&Stepper: set style. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper 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
($&Stepper) clear_style
pub fn (st $&Stepper) clear_style()
Purpose
Operation on $&Stepper: clear style.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
Returns
This call does not return a value.
($&Stepper) input
pub fn (st $&Stepper) input(input &ui.InputEvent) Action
Purpose
Process routed mouse, keyboard, or touch input events. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
input &ui.InputEvent- input (read-only borrow; caller keeps the original; type &ui.InputEvent)
Returns
Action — input result with kind, id, repaint and focus requests.
($&Stepper) event
pub fn (st $&Stepper) event(event &ui.Event) Action
Purpose
Handle and respond to window or system lifecycle and interaction events. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
event &ui.Event- event (read-only borrow; caller keeps the original; type &ui.Event)
Returns
Action — input result with kind, id, repaint and focus requests.
(&Stepper) paint
pub fn (st &Stepper) paint(frame $&draw.Frame,label &draw.TextLayout,theme &Theme) int
Purpose
Paint the control visually onto the target canvas. Throws on failure; handle the error or propagate it to the caller.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
frame $&draw.Frame- frame (exclusive borrow; may modify the original; type $&draw.Frame)
label &draw.TextLayout- label (read-only borrow; caller keeps the original; type &draw.TextLayout)
theme &Theme- theme (read-only borrow; caller keeps the original; type &Theme)
Returns
int — a value of this type
(&Stepper) measure_styled
pub fn (st &Stepper) measure_styled(label $&StyledLabel,styles &Styles) layout.Size
Purpose
Operation on &Stepper: measure styled. Throws on failure; handle the error or propagate it to the caller.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
label $&StyledLabel- label (exclusive borrow; may modify the original; type $&StyledLabel)
styles &Styles- styles (read-only borrow; caller keeps the original; type &Styles)
Returns
layout.Size — a value of this type
(&Stepper) paint_styled
pub fn (st &Stepper) paint_styled(frame $&draw.Frame,label $&StyledLabel,styles &Styles) int
Purpose
Operation on &Stepper: paint styled. Throws on failure; handle the error or propagate it to the caller.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
frame $&draw.Frame- frame (exclusive borrow; may modify the original; type $&draw.Frame)
label $&StyledLabel- label (exclusive borrow; may modify the original; type $&StyledLabel)
styles &Styles- styles (read-only borrow; caller keeps the original; type &Styles)
Returns
int — a value of this type
($&Stepper) set_repeat
pub fn (st $&Stepper) set_repeat(enabled bool,delay time.Duration,interval time.Duration) int
Purpose
Operation on $&Stepper: set repeat. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
delay time.Duration- delay (time.Duration)
interval time.Duration- interval (time.Duration)
Returns
int — a value of this type
($&Stepper) apply_styles
pub fn (st $&Stepper) apply_styles(styles &Styles) int
Purpose
Resolve and apply theme metrics to the control. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper 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
(&Stepper) next_tick
pub fn (st &Stepper) next_tick(now time.Instant) time.Instant
Purpose
Operation on &Stepper: next tick. Throws on failure; handle the error or propagate it to the caller.
Parameters
st &Stepper- The
Stepper instance used by this call (borrow).
now time.Instant- now (time.Instant)
Returns
time.Instant — a value of this type
($&Stepper) tick
pub fn (st $&Stepper) tick(now time.Instant) Action
Purpose
Advance animation clock and state transition step. Throws on failure; handle the error or propagate it to the caller.
Parameters
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
now time.Instant- now (time.Instant)
Returns
Action — input result with kind, id, repaint and focus requests.
($&Stepper) route
pub fn (st $&Stepper) route(kind int,input &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
st $&Stepper- The
Stepper instance used by this call (exclusive borrow).
kind int- kind tag (int)
input &ui.InputEvent- input (read-only borrow; caller keeps the original; type &ui.InputEvent)
Returns
Action — input result with kind, id, repaint and focus requests.
Complete native example
Component Workshop · Back to Widgets