Components / controls
MentionInput view
A multiline editor with one caret-anchored mention completion surface.
A view survives a frame. Hold it in an Entity with cx.new(..) and reach it with .update(..).
use gpui_kit::controls::mention::MentionInput;
Reviewed in mention-input.
Construct
new(ident: impl Into<Ident>, editor: Entity<TextArea>, cx: &mut Context<Self>) -> Self
Options
Chain onto the value.
suggestions(suggestions: AsyncValue<Vec<MentionCandidate>, SharedString>) -> Self
candidates(candidates: impl IntoIterator<Item = MentionCandidate>) -> Self
Commands
Need a Context, so they need a view.
set_suggestions(suggestions: AsyncValue<Vec<MentionCandidate>, SharedString>, cx: &mut Context<Self>)
Queries
Only answer; they change nothing.
suggestions_state() -> &AsyncValue<Vec<MentionCandidate>, SharedString>
editor() -> &Entity<TextArea>
active_query() -> Option<&MentionQuery>
is_open() -> bool
Reports
The variants of the event it emits. It never applies the change itself.
- Changed
- Submitted
- Cancelled
- Pasted
- Focused
- Blurred
- QueryChanged
- Accepted
Example · mention-input
fn mention_input(window: &mut Window, cx: &mut App) -> AnyElement {
ensure_mention_input(window, cx);
let input = cx.global::<SceneMentionInput>().input.clone();
let theme = cx.theme().clone();
div()
.column()
.gap_token(&theme, Space::Sm)
.p_token(&theme, Space::Lg)
.w(px(420.0))
.child(caption(
&theme,
"the editor owns text; the anchored menu owns only @query completion",
))
.child(input)
.into_any_element()
}