gpui-kit GitHub

Components

Select view

A closed list of options with one answer.

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

use gpui_kit::controls::Select;

Construct

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

Options

Chain onto the value.

options(options: impl IntoIterator<Item = SelectOption>) -> Self
selected(id: impl Into<SharedString>) -> Self
placeholder(placeholder: impl Into<SharedString>) -> Self
invalid(invalid: bool) -> Self

Commands

Need a Context, so they need a view.

set_options(options: Vec<SelectOption>, cx: &mut Context<Self>)
set_selected(id: Option<SharedString>, cx: &mut Context<Self>)
set_disabled(disabled: bool, cx: &mut Context<Self>)

Queries

Only answer; they change nothing.

selected_id() -> Option<&SharedString>
selected_option() -> Option<&SelectOption>
is_open() -> bool

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/select.rs