gpui-kit GitHub

Components

KeybindingRecorder view

A field that records one keystroke.

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

use gpui_kit::controls::KeybindingRecorder;

Construct

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

Options

Chain onto the value.

label(label: impl Into<SharedString>) -> Self
placeholder(placeholder: impl Into<SharedString>) -> Self
binding(binding: impl Into<SharedString>) -> Self
conflict(reason: Option<impl Into<SharedString>>) -> Self
allow_escape(allow: bool) -> Self

Commands

Need a Context, so they need a view.

set_binding(binding: Option<SharedString>, cx: &mut Context<Self>)
set_conflict(reason: Option<SharedString>, cx: &mut Context<Self>)
start(window: &mut Window, cx: &mut Context<Self>)
cancel(cx: &mut Context<Self>)

Queries

Only answer; they change nothing.

is_recording() -> bool
current_binding() -> Option<&SharedString>

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