Expand description
HexColorInput — single-line #RRGGBB[AA] color editor.
A specialization of TextInput that wires an input mask, a
hex-digit character filter, and a strict commit-time validator on top
of the standard text-editing surface. Bound to a Signal<Color>
(required) or Signal<Option<Color>> (nullable). External writes to
the bound signal reformat the field text — but only when the field
is unfocused, so a user typing “FF” in the middle of a long color
code isn’t clobbered by a sibling widget tweaking the value.
§Behaviour
- Parsing:
#RRGGBB(case-insensitive);#RRGGBBAAifalpha_enabled;#RGBshort-form expands to#RRGGBBifshort_form_enabled. Each accepted form may be normalized to uppercase on commit (configurable). - Char filter: only
[0-9a-fA-F#]admitted while typing. - Mask:
\\#hhhhhh(or\\#hhhhhhhhwith alpha) — theTextInputFieldmask grammar (h= hex digit slot,\\literal escape). - Validation: commits on Enter / Tab-out / blur. Returns
ValidationOutcome::Valid/ValidationOutcome::Corrected/ValidationOutcome::Invalidwhich the inner field maps to a visible inline strip via the standardvalidation_feedbackbridge. - Nullable: empty (after trim) commits
None; non-empty parses normally and commitsSome(color).
§Example
ⓘ
let color = ctx.signal(Color::from_hex("#3584E4"));
ctx.add(
HexColorInput::new(color)
.alpha_enabled(true)
.label("Background"),
);Structs§
- HexColor
Input - Single-line hex color editor.