Closed XOR-op closed 1 year ago
Here's something I found so far for the LeftClick
issue:
In tao, we delegate the menu
to tray_target
while building SystemTray
However, when we set a new menu, we didn't delegate it to tray_target
; I guess this would cause some issues.
So I track into the set_menu. I tried getting tray_target
from the button
and let the new menu set delegate to it. The LeftClick
event is emitted again in an ugly way lol
pub fn set_menu(&mut self, tray_menu: &Menu) {
unsafe {
self.ns_status_bar.setMenu_(tray_menu.menu);
let button: id = self.ns_status_bar.button();
let tray_target: id = msg_send![button, target];
let () = msg_send![tray_menu.menu, setDelegate: tray_target];
}
}
I'm not sure if this is the root cause or just some lucky guess. If we decide to fix like this way, we might need to store the tray_target
somewhere in SystemTray
struct?
@pewsheen yeah the set_menu
function is not correct at all, please open a PR and we will discuss it more there
Describe the bug
When trying to call
set_menu
with tray_handle inon_system_tray_event
callback, tauri's behavior is weird. Let's break into two part:SystemTrayEvent::LeftClick
: event handled successfully,set_menu
returnsOk()
, but in fact failed to replace tray menuSystemTrayEvent::MenuItemClick
: event handled successfully,set_menu
returnsOk()
, successfully replace tray menuset_menu
bySystemTrayEvent::MenuItemClick
:SystemTrayEvent::LeftClick
: event not handled, #5842 has similar bug reportSystemTrayEvent::MenuItemClick
: event handled successfully,set_menu
returnsOk()
, successfully replace tray menuThe
RightClick
seems to have similar bugs. I'm not sure if these two buggy behaviors are related, but I believe they may have the same root cause. I tested this bug on both 1.4.1 and 2.0.0-alpha-10.Reproduction
Minimal repo in https://github.com/XOR-op/tauri-bug-reproduction
Expected behavior
Ok()
; and it should work at most cases.Platform and versions
Stack trace
No response
Additional context
No response