gpui-component icon indicating copy to clipboard operation
gpui-component copied to clipboard

macos menu can't bind action, only app titlebar menu invoke ation well

Open lamb opened this issue 2 months ago • 2 comments

macos menu can't bind action, only app titlebar menu invoke ation well. I didn't test Linux because there is currently no Linux environment. How can I bind all ? Can you show an example? Thanks.

fn on_select_about(&mut self, _: &About, window: &mut Window, cx: &mut Context<Self>) {
    tracing::error!("on action about...");
    window.open_modal(cx, |modal, _, _| {
        modal.title("About").child("This is a about dialog.")
    })
}

impl Render for AppTitleBar {
    fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        let notifications_count = window.notifications(cx).len();
        TitleBar::new()
            // left side
            .child(
                div()
                    .on_action(cx.listener(Self::on_select_about))
                    .flex()
                    .items_center()
                    .child(self.app_menu_bar.clone()),
            )
            .child(
                ...
            )
    }
}
Image Image

lamb avatar Oct 26 '25 11:10 lamb

I suppose, since gpui-component provide only set of components, they are not binding it with system APIs or something like this, you will need to add a second implementation for system menu itself, maybe share content between implementations somehow

SiriusCrain avatar Oct 26 '25 20:10 SiriusCrain

Not a bug, that just I have not implemented About action, so the system menu is disabled (Is correct). But the AppMenuBar not disabled (This because GPUI current not have API for let us disable it, it will improve it)

I will complete that when I have time.

huacnlee avatar Oct 27 '25 12:10 huacnlee