gpui-kit GitHub

Components

CopyButton view

A button that copies caller-supplied text and confirms what happened.

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

use gpui_kit::controls::CopyButton;

Construct

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

Options

Chain onto the value.

text(text: impl Into<SharedString>) -> Self
label(label: impl Into<SharedString>) -> Self
glyph_only(name: impl Into<SharedString>) -> Self
variant(variant: ButtonVariant) -> Self
copier(copier: impl Fn(&str, &mut App) -> Result<(), SharedString> + 'static) -> Self
confirmation(confirmation: Duration) -> Self

Commands

Need a Context, so they need a view.

set_text(text: impl Into<SharedString>, cx: &mut Context<Self>)
set_disabled(disabled: bool, cx: &mut Context<Self>)
copy(cx: &mut Context<Self>)

Queries

Only answer; they change nothing.

state() -> &CopyState

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