GPUI Box GitHub

Components

OneTimeCodeInput view

One sensitive editor presented as a bounded run of visual slots.

A view survives a frame. Hold it in an Entity with cx.new(..) and reach it with .update(..).

use gpui_kit::controls::OneTimeCodeInput;

Construct

new(ident: impl Into<Ident>, window: &mut Window, cx: &mut Context<Self>) -> Self

Options

Chain onto the value.

name(name: impl Into<SharedString>) -> Self
text(text: impl Into<SharedString>) -> Self
slots(slots: usize) -> Self
invalid(invalid: bool) -> Self
required(required: bool) -> Self
read_only(read_only: bool) -> Self

Commands

Need a Context, so they need a view.

set_value(value: impl Into<SharedString>, cx: &mut Context<Self>)
set_disabled(disabled: bool, cx: &mut Context<Self>)
set_read_only(read_only: bool, cx: &mut Context<Self>)
set_invalid(invalid: bool, cx: &mut Context<Self>)

Queries

Only answer; they change nothing.

value(cx: &App) -> SharedString
len(cx: &App) -> usize
is_empty(cx: &App) -> bool
is_complete(cx: &App) -> bool
slot_count() -> usize

Reports

The variants of the event it emits. It never applies the change itself.

Rendered by

Each of these compiles and is captured by the gate, so the code behind them is verified rather than written.

Source: crates/gpui-kit/src/controls/auth.rs