Skip to main content

VisualContext

Derive Macro VisualContext 

Source
#[derive(VisualContext)]
{
    // Attributes available to this derive:
    #[window]
    #[app]
}
Expand description

Derives gpui::VisualContext for a struct that holds a &mut gpui::App and a &mut gpui::Window.

Mark the &mut App field with #[app] and the &mut Window field with #[window]. Both attributes are required. The derived methods forward to those fields.

Failing to add either attribute causes a compile error:

ⓘ
#[derive(VisualContext)]
struct MyContext<'a, 'b> {
    #[app]
    app: &'a mut gpui::App,
    window: &'b mut gpui::Window
}
ⓘ
#[derive(VisualContext)]
struct MyContext<'a, 'b> {
    app: &'a mut gpui::App,
    #[window]
    window: &'b mut gpui::Window
}