Skip to main content

Module text_input_field

Module text_input_field 

Source
Expand description

TextInputField — raw editable text surface primitive built on the text-typeset / text-document stack. Consumed by TextInput (the styled composite) and SpinBox (numeric input) and available to third-party composites that need inline editable text. TextInputField — editable single-line text surface primitive.

This is the raw editing primitive that powers the styled TextInput composite and any other widget that needs inline editable text — SpinBox being the primary second consumer.

Unlike TextInput, TextInputField paints no frame, no placeholder overlay, no validation border, and hosts no trailing slots: it is the focusable text area only. Compose it yourself with RectWidget, Padding, icons, clear buttons, etc. to build a styled control. Focus indication is the composite’s responsibility — the Int UI convention is to thicken the enclosing frame’s border to focus_ring_width and recolor it to the accent focus-ring color.

Features:

  • Bound Signal<String> for two-way text binding.
  • Full keyboard editing (arrow keys, Home/End, Backspace/Delete, Ctrl+X/C/V, Ctrl+A, Ctrl+Z/Y), IME commit, and pointer caret positioning and drag-select.
  • Optional per-character input filter (TextInputField::char_filter), max-length cap (TextInputField::max_length), and read-only mode (TextInputField::read_only).
  • Commit hooks: Enter fires on_submit_fn and focus loss fires on_blur_fn.
  • Non-editable trailing suffix, rendered flush-right inside the field’s bounds (Qt’s QSpinBox::suffix). Caret cannot enter it; clicks past the text end clamp to the last character.
  • Right-click context menu (Cut / Copy / Paste / Select All).
  • AccessKit Role::TextInput with value, selection, and character/word boundary metadata.

§Example

let text = ctx.signal(String::new());
ctx.add(
    TextInputField::new(text.clone())
        .placeholder("Enter a name…")
        .char_filter(|c| !c.is_ascii_digit())
        .on_submit_fn(|ctx| ctx.send_intent(MyIntent::Save)),
);

Re-exports§

pub use self::mask::InputMask;
pub use self::mask::MaskClass;
pub use self::mask::MaskError;
pub use self::mask::MaskPosition;
pub use self::validator::ValidationFeedback;
pub use self::validator::ValidationOutcome;
pub use self::validator::ValidatorFn;

Modules§

mask
Input-mask grammar (Qt-compatible subset).
validator
Validation pipeline shared by TextInputField and the composites that render its feedback (TextInput, DateEdit, TimeEdit, DateTimeEdit).

Structs§

TextFieldHandle
A live handle on a TextInputField — its text-editing commands, for a caller outside the widget.
TextInputField
Editable single-line text surface primitive.

Enums§

AtRevealPolicy
How a revealed secure field reports to assistive technology.
EchoMode
How a secure (TextInputField::secure) field echoes typed characters. Mirrors Qt’s QLineEdit::EchoMode.
InputPurpose
The semantic purpose of a text field, surfaced to assistive technology as a specialised AccessKit role (WCAG 1.3.5 Identify Input Purpose / EN 301 549).