tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.53k stars 2.58k forks source link

[bug] Blank Menu Bar - Menu Items Not Showing Up #11576

Closed rooseveltrp closed 3 weeks ago

rooseveltrp commented 3 weeks ago

Describe the bug

Hi,

I cannot figure out how to add menu items to a Tauri 2.0.6 app. The following code compiles but there's no menu item showing up. It's completely blank on macOS.

src-tauri/src/main.rs

// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use tauri::menu::*;

fn main() {
    tauri::Builder::default()
        .setup(|app| {
            let toggle = MenuItemBuilder::with_id("toggle", "Toggle").build(app)?;
            let check = CheckMenuItemBuilder::new("Mark").build(app)?;
            let menu = MenuBuilder::new(app).items(&[&toggle, &check]).build()?;

            app.set_menu(menu)?;

            app.on_menu_event(move |app, event| {
                if event.id() == check.id() {
                    println!(
                        "`check` triggered, do something! is checked? {}",
                        check.is_checked().unwrap()
                    );
                } else if event.id() == "toggle" {
                    println!("toggle triggered!");
                }
            });
            Ok(())
        })
        .plugin(tauri_plugin_fs::init())
        .plugin(tauri_plugin_dialog::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

image

What step am I missing?

Reproduction

No response

Expected behavior

Next to the App icon, it should show the App Name, followed by the menu items.

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.6.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 18.20.4
    - pnpm: 8.10.3
    - npm: 9.9.3

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.5
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : 2.0.1
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1
    - tauri-plugin-dialog 🦀: 2.0.3
    - @tauri-apps/plugin-dialog : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../src

Stack trace

No response

Additional context

No response

amrbashir commented 3 weeks ago

On macOS, the root menu can only have submenus, the documentation will be updated in the next relaese.