Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for global menus on macOS #197

Open
dominikwilkowski opened this issue Nov 21, 2023 · 0 comments
Open

Support for global menus on macOS #197

dominikwilkowski opened this issue Nov 21, 2023 · 0 comments
Labels
P: macos Platform: macos S: help wanted Status: Extra attention is needed T: bug Type: Something isn't working

Comments

@dominikwilkowski
Copy link
Contributor

dominikwilkowski commented Nov 21, 2023

It looks like there is an issue with the winit implementation since the menu code is commented out in the code base right now.
Possibly related to #17?
I figured I add an issue to track this.

We should have support for:

Application::new()
	.window(
		|_| {
			app_view().window_title(|| String::from("Title")).window_menu(|| {
				Menu::new("Foobar")
					.entry(MenuItem::new("Menu item"))
					.entry(MenuItem::new("Menu item with something on the\tright"))
			})
		},
		Some(WindowConfig::default().size(Size::new(800.0, 350.0)).title("Vault")),
	)
	.run();

The window_handle.rs function can be made to compile like this:

fn update_window_menu(&mut self, mut menu: Menu) {
    if let Some(action) = menu.item.action.take() {
        self.app_state
            .window_menu
            .insert(menu.item.id as usize, action);
    }
    for child in menu.children {
        match child {
            crate::menu::MenuEntry::Separator => {}
            crate::menu::MenuEntry::Item(mut item) => {
                if let Some(action) = item.action.take() {
                    self.app_state.window_menu.insert(item.id as usize, action);
                }
            }
            crate::menu::MenuEntry::SubMenu(m) => {
                self.update_window_menu(m);
            }
        }
    }
}

Which would result in a global menu much like this one in macos:
image

@panekj panekj added T: bug Type: Something isn't working S: help wanted Status: Extra attention is needed labels Dec 9, 2023
@jrmoulton jrmoulton pinned this issue Nov 4, 2024
@jrmoulton jrmoulton changed the title Support for global menus Support for global menus on macOS Nov 6, 2024
@jrmoulton jrmoulton added the P: macos Platform: macos label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P: macos Platform: macos S: help wanted Status: Extra attention is needed T: bug Type: Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants