macos menu can't bind action, only app titlebar menu invoke ation well
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(
...
)
}
}
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
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.