module
UI::FormStateRendererHook
Overview
Renderer-side helper called from visit(UI::TextField) /
visit(UI::SecureField) on the native renderers. Encapsulates the
"if view.name is non-empty, register the initial value + wrap the
author's on_change so it ALSO updates FormState with mount-token
guarding" pattern, so the renderer code stays slim.
Defined in:
ui/form_state.crClass Method Summary
-
.wrap_secure_handler(view : UI::SecureField) : Proc(String, Nil) | Nil
Wrap a SecureField's on_change.
-
.wrap_text_handler(view : UI::TextField) : Proc(String, Nil) | Nil
Wrap a TextField's on_change.
Class Method Detail
Wrap a SecureField's on_change. Same shape as .wrap_text_handler
but typed for SecureField. The current SwiftKit bridge for
SecureField does NOT carry the cleartext through to Crystal — the
action token only signals "something changed" and the user's
on_change is invoked with "". form_state.update therefore writes
an empty string for the SecureField's name. Authors who need true
password capture on macOS / iOS for Phase 8B should use a plain
UI::TextField for now. A future SwiftKit bridge iteration will
carry the actual typed password.
Wrap a TextField's on_change. Returns:
- nil if neither the view has a
namenor a user-supplied on_change (no wiring needed). - the original on_change if the view has no
name. - a new proc that ALSO updates form_state (mount-token-checked) before invoking the original on_change.