CUI

Components / Inputs

Scrub field

A number you change by dragging sideways on it, as in design and 3D tools.

Functions: cui_scrub

Scrub field

Usage

static float opacity = 80;
cui_scrub(ui, "Opacity", &opacity, 0, 100, .suffix = "%");

Drag sideways anywhere on the field to change the value; hold Shift for steps ten times finer. A click without dragging lets you type a number. Arrow keys step when focused. A hairline along the bottom shows where the value sits in its range. Options: step (range / 100), format, suffix, icon (instead of the label), width.

Keyboard

  • Drag sideways anywhere on the field to change the value; hold Shift for steps ten times finer.

Options of cui_scrub

OptionTypeDefaultDescription
.stepfloat(max - min) / 100default (max - min) / 100
.formatconst char *"%.0f"default "%.0f"
.suffixconst char *e.g. "px" or "%"
.iconconst char *shown instead of the label
.widthcui_sizeWidth: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own.

Related

  • Money field: A field for an amount of money, with a currency symbol and grouped digits.
  • Inline edit: Text that turns into a field when clicked, for renaming things in place.
  • Prefix and suffix: Fixed text before or after a field's value, such as https:// or a unit.
  • Password strength: A meter under a password field that scores the password from too short to strong.