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

[feat] Tray add set_title API #3322

Closed
awkj opened this issue Feb 2, 2022 · 6 comments
Closed

[feat] Tray add set_title API #3322

awkj opened this issue Feb 2, 2022 · 6 comments
Labels
platform: macOS status: backlog Issue is ready and we can work on it status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes type: feature request

Comments

@awkj
Copy link

awkj commented Feb 2, 2022

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 awkj changed the title [feat] Tray API add set_title [feat] Tray add set_title API Feb 2, 2022
@amrbashir
Copy link
Member

amrbashir commented Feb 2, 2022

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

@awkj
Copy link
Author

awkj commented Feb 2, 2022

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

@amrbashir
Copy link
Member

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

@awkj
Copy link
Author

awkj commented Feb 2, 2022

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)

@tauri-apps tauri-apps bot added the status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes label Feb 2, 2022
@amrbashir
Copy link
Member

amrbashir commented Feb 2, 2022

upstream issue tauri-apps/tao#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

@tauri-apps tauri-apps deleted a comment from tauri-apps bot Jul 26, 2022
vojty added a commit to vojty/tauri that referenced this issue Sep 13, 2022
vojty added a commit to vojty/tauri that referenced this issue Sep 20, 2022
@amrbashir amrbashir added status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes status: backlog Issue is ready and we can work on it and removed status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes labels Sep 30, 2022
@probablykasper
Copy link
Member

I think this was added in v1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: macOS status: backlog Issue is ready and we can work on it status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes type: feature request
Projects
None yet
Development

No branches or pull requests

3 participants