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

[bug] On MacOS when a new system_tray_menu is set the on_system_tray_event handler is no longer called #5842

Closed
rikschennink opened this issue Dec 15, 2022 · 1 comment
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@rikschennink
Copy link

rikschennink commented Dec 15, 2022

Describe the bug

  1. I set a menu during build as described in docs here

  2. Then later in a command from front-end I set a a new menu but now the on_system_tray_event handler is no longer called.

I tried to replace the entire system tray but that causes the app to crash on right click. See stack trace.

I'm super new to Rust so this could very well all be incompetence. Grateful for any feedback / ideas. I've also opened a Stack Overflow issue to cover the incompetence situation

Reproduction

Updating the menu resulting in events no longer working

#[tauri::command]
fn set_system_tray_menu(app: AppHandle) {

    let menu = SystemTrayMenu::new()
      .add_item(CustomMenuItem::new("test".to_string(), "Test"));

    match app.tray_handle().set_menu(menu) {
      Ok(_) => {},
      Err(error) => panic!("Problem setting system tray menu: {}", error),
    };

}

Replacing the menu causing a crash

fn set_system_tray_menu(app: AppHandle) {

    let menu = SystemTrayMenu::new()
      .add_item(CustomMenuItem::new("test".to_string(), "Test"));
    
    match SystemTray::new().with_menu(menu).build(&app) {
      Ok(_) => {},
      Err(error) => panic!("Problem setting system tray menu: {}", error),
    };

}

Expected behavior

Either one of these:

  1. The on_system_tray_event event handlers keep working
  2. A way to assign new event handlers

Platform and versions

MacOS 12.6

Stack trace

2022-12-15 14:59:48.060 hotlist-tauri[49478:21361707] -[_WKInspectorConfiguration _setMenuOwner:]: unrecognized selector sent to instance 0x13e7ecdd0
thread 'main' panicked at 'Uncaught exception <NSException: 0x13e709a30>', /Users/rikschennink/.cargo/registry/src/github.com-1ecc6299db9ec823/cocoa-0.24.1/src/appkit.rs:3740:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional context

No response

@rikschennink rikschennink added status: needs triage This issue needs to triage, applied to new issues type: bug labels Dec 15, 2022
@rikschennink rikschennink changed the title [bug] when I set a new tray_menu I lose the on_system_tray_event [bug] When I set a new system_tray_menu I lose the .on_system_tray_event() handler Dec 15, 2022
@rikschennink rikschennink changed the title [bug] When I set a new system_tray_menu I lose the .on_system_tray_event() handler [bug] When a new system_tray_menu is set the on_system_tray_event handler is no longer called Dec 15, 2022
@rikschennink rikschennink changed the title [bug] When a new system_tray_menu is set the on_system_tray_event handler is no longer called [bug] On MacOS when a new system_tray_menu is set the on_system_tray_event handler is no longer called Dec 19, 2022
@amrbashir
Copy link
Member

will be fixed in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants