I am trying to add .on_tray_icon_event on my menu bar application but it is not working. I need to apply positioning but it doesn't even go inside this code
I am using https://v2.tauri.app/learn/system-tray/#listen-to-tray-events as reference
.on_tray_icon_event(|tray, event| {
let app = tray.app_handle();
tauri_plugin_positioner::on_tray_event(app.app_handle(), &event);
println!("positioning applied");
if let TrayIconEvent::Click {
button: MouseButton::Left,
button_state: MouseButtonState::Up,
..
} = event
{
if let Some(window) = app.get_webview_window("main") {
println!("{}", window.is_visible().unwrap());
if window.is_visible().unwrap_or(false) {
println!("hiding.....");
let _ = window.hide();
} else {
println!("positioning.....");
let _ =
window.move_window(tauri_plugin_positioner::Position::TrayBottomCenter);
let _ = window.show();
let _ = window.set_focus();
}
}
}
})