gpui-kit GitHub

Components

Menu view

A list of commands, opened from a trigger.

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

use gpui_kit::overlay::Menu;

Construct

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

Options

Chain onto the value.

trigger(label: impl Into<SharedString>) -> Self
trigger_icon(glyph: Icon) -> Self
trigger_name(name: impl Into<SharedString>) -> Self
trigger_variant(variant: ButtonVariant) -> Self
trigger_join(join: ButtonJoin) -> Self
items(items: impl IntoIterator<Item = MenuItem>) -> Self
placement(placement: Placement) -> Self

Commands

Need a Context, so they need a view.

set_trigger_name(name: impl Into<SharedString>, cx: &mut Context<Self>)
set_trigger_style(variant: ButtonVariant, size: ControlSize, cx: &mut Context<Self>)
set_items(items: Vec<MenuItem>, cx: &mut Context<Self>)
open(window: &mut Window, cx: &mut Context<Self>)
open_submenu(id: &str, window: &mut Window, cx: &mut Context<Self>) -> bool
close(window: &mut Window, cx: &mut Context<Self>)
dismiss(window: &mut Window, cx: &mut Context<Self>)
toggle(window: &mut Window, cx: &mut Context<Self>)

Queries

Only answer; they change nothing.

offered() -> &[MenuItem]
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/overlay/menu.rs