GPUI Box GitHub

Components / controls

InlineEdit builder

Text that a click or enter turns into a field.

A builder is RenderOnce. Construct and mount it in one expression.

use gpui_kit::controls::inline_edit::InlineEdit;

Reviewed in inline-edit.

Construct
new(ident: impl Into<Ident>, value: impl Into<SharedString>) -> Self
Options

Chain onto the value.

placeholder(placeholder: impl Into<SharedString>) -> Self
editing(editing: bool) -> Self
multiline(multiline: bool) -> Self
rows(rows: usize) -> Self
failure(failure: impl Into<SharedString>) -> Self
on_edit(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
on_commit(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
on_cancel(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
Example · inline-edit
fn inline_edit(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    stack(&theme)
        .w(px(420.0))
        .child(caption(
            &theme,
            "reading, editing, and a save that did not take",
        ))
        .child(
            InlineEdit::new("scene.inline-edit.title", "Indexing the workspace")
                .on_edit(|_, _| {})
                .on_commit(|_, _, _| {})
                .on_cancel(|_, _| {}),
        )
        .child(
            InlineEdit::new("scene.inline-edit.owner", "fixture-owner")
                .editing(true)
                .on_edit(|_, _| {})
                .on_commit(|_, _, _| {})
                .on_cancel(|_, _| {}),
        )
        .child(
            InlineEdit::new(
                "scene.inline-edit.note",
                "Retry after the host is reachable",
            )
            .editing(true)
            .failure("The host refused this change. What you typed is still here.")
            .on_edit(|_, _| {})
            .on_commit(|_, _, _| {})
            .on_cancel(|_, _| {}),
        )
        .child(
            InlineEdit::new("scene.inline-edit.policy", "Set by the administrator")
                .disabled(true)
                .on_edit(|_, _| {}),
        )
        .into_any_element()
}

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