Skip to content

UXStepper

UXStepper is the small two-part control beside a numeric field. The top half steps the value up and the bottom half steps it down, clamped to a range or, if requested, wrapping. The value logic is pure and unit-testable. Drawing and the up/down hit-test go through the UXControl seam. Where the platform has a native stepper (macOS NSStepper, Win32 up-down, iOS UIStepper, GTK GtkSpinButton) the driver realizes one; elsewhere the control draws the theme’s stepper.up / stepper.down bezels.

#use <UXKit>
UXStepper* qty = new UXStepper();
qty.setRange(1, 99);
qty.setValue(1);
qty.setAction(&controller.onQty);
content.addSubview(qty, UXGeom.make(96, 8, 20, 24));

The action fires after each step; the handler reads the value from the sender:

void onQty(UXControl* sender) {
field.setText(itoa(((UXStepper* ?)sender).intValue()));
}
  • Inherits UXControl: the weak: callback action, enablement, the fire path.

Value · setRange · setStep · setWraps · setValue · intValue Stepping · increment · decrement

void setRange(i32 lo, i32 hi)

Sets the bounds and clamps the current value into them.

void setStep(i32 s)

The per-click delta (a non-positive step is repaired to 1).

void setWraps(bool w)

Whether stepping past an end wraps to the other end. A clock’s minutes wrap; a quantity doesn’t.

void setValue(i32 v)

Sets the value programmatically, clamped. Does not fire the action.

i32 intValue(void)

The current value. The neutral object holds it, whatever realized the control.

void increment(void)

One step up: clamps at the top, or wraps to the minimum when setWraps is set.

void decrement(void)

One step down, the mirror of increment.

UXStepper on the web backend

The theme’s stepper.up / stepper.down bezels at their natural 25×25, never stretched. The same Aristo art GEM draws, on canvas.

A stepper driving a field:

UXTextField* qtyField = new UXTextField();
UXStepper* qtySteps = new UXStepper();
qtySteps.setRange(1, 99);
qtySteps.setAction(&controller.onQty);
content.addSubview(qtyField, UXGeom.make(8, 8, 84, 24));
content.addSubview(qtySteps, UXGeom.make(96, 8, 20, 24));