tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[feat] Tray add set_title API

Open awkj opened this issue 3 years ago • 5 comments

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

awkj avatar Feb 02 '22 14:02 awkj

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

amrbashir avatar Feb 02 '22 14:02 amrbashir

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

image

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

image

awkj avatar Feb 02 '22 15:02 awkj

oh my bad, this is a macOS specific thing, I will upstream it to Tao.

amrbashir avatar Feb 02 '22 15:02 amrbashir

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)

awkj avatar Feb 02 '22 15:02 awkj

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

amrbashir avatar Feb 02 '22 16:02 amrbashir

I think this was added in v1.2

probablykasper avatar Nov 09 '22 01:11 probablykasper