tauri
tauri copied to clipboard
[feat] Tray add set_title API
Describe the problem
I use tauri build menubar application ,but I found tauri rust api not have set_title to set title only have set_icon and set_icon_as_template
impl<R: Runtime> SystemTrayHandle<R> {
/// Gets a handle to the menu item that has the specified `id`.
pub fn get_item(&self, id: MenuIdRef<'_>) -> SystemTrayMenuItemHandle<R> {
for (raw, item_id) in self.ids.iter() {
if item_id == id {
return SystemTrayMenuItemHandle {
id: *raw,
tray_handler: self.inner.clone(),
};
}
}
panic!("item id not found")
}
/// Updates the tray icon. Must be a [`Icon::File`] on Linux and a [`Icon::Raw`] on Windows and macOS.
pub fn set_icon(&self, icon: Icon) -> crate::Result<()> {
self.inner.set_icon(icon).map_err(Into::into)
}
/// Support [macOS tray icon template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc) to adjust automatically based on taskbar color.
#[cfg(target_os = "macos")]
pub fn set_icon_as_template(&self, is_template: bool) -> crate::Result<()> {
self
.inner
.set_icon_as_template(is_template)
.map_err(Into::into)
}
}
Describe the solution you'd like
add API set_title like
Alternatives considered
No response
Additional context
No response
do you mean system tray tooltip or change a menu item's title in the system tray menu? because the code you posted is for SystemTray
do you mean system tray tooltip or change a menu item's title in the system tray menu? because the code you posted is for SystemTray

I mean system tary menu, API document on https://tauri.studio/docs/guides/system-tray
I want use tauri make a tool for display network speed on mac(previoue version is use electron write) , electron have API tray.setTitle(title[, options]) (https://www.electronjs.org/docs/latest/api/tray)
I try use a canvas to instead of text, but icon should have limit on width( only have icon width).
This is a comparison of electron and tauri, electron setImage API can show any pictures size

oh my bad, this is a macOS specific thing, I will upstream it to Tao.
oh my bad, this is a macOS specific thing, I will upstream it to Tao.
you will add two API, one is set_title , and other is set_image(allow set canvas/other image) ?
or only keep set_image API , set_icon is image's special case?( electron is do it)
upstream issue https://github.com/tauri-apps/tao/issues/65
or only keep set_image API , set_icon is image's special case?( electron is do it)
These apis won't be implemented for Tauri v1 and will wait until v2, I have upstreamed set_title and once we do it, we can surely add set_image
I think this was added in v1.2