@@ -64,6 +64,7 @@ pub struct SystemTray {
6464 icon_as_template_set : bool ,
6565 #[ cfg( target_os = "macos" ) ]
6666 title : Option < String > ,
67+ tooltip : Option < String > ,
6768}
6869
6970impl fmt:: Debug for SystemTray {
@@ -98,6 +99,7 @@ impl Default for SystemTray {
9899 menu_on_left_click_set : false ,
99100 #[ cfg( target_os = "macos" ) ]
100101 title : None ,
102+ tooltip : None ,
101103 }
102104 }
103105}
@@ -257,6 +259,29 @@ impl SystemTray {
257259 self
258260 }
259261
262+ /// Sets the tray icon tooltip.
263+ ///
264+ /// ## Platform-specific:
265+ ///
266+ /// - **Linux:** Unsupported
267+ ///
268+ /// # Examples
269+ ///
270+ /// ```
271+ /// use tauri::SystemTray;
272+ ///
273+ /// tauri::Builder::default()
274+ /// .setup(|app| {
275+ /// let tray_handle = SystemTray::new().with_tooltip("My App").build(app)?;
276+ /// Ok(())
277+ /// });
278+ /// ```
279+ #[ must_use]
280+ pub fn with_tooltip ( mut self , tooltip : & str ) -> Self {
281+ self . tooltip = Some ( tooltip. to_owned ( ) ) ;
282+ self
283+ }
284+
260285 /// Sets the event listener for this system tray.
261286 ///
262287 /// # Examples
@@ -414,6 +439,10 @@ impl SystemTray {
414439 }
415440 }
416441
442+ if let Some ( tooltip) = self . tooltip {
443+ runtime_tray = runtime_tray. with_tooltip ( & tooltip) ;
444+ }
445+
417446 let id = runtime_tray. id ;
418447 let tray_handler = match manager. runtime ( ) {
419448 RuntimeOrDispatch :: Runtime ( r) => r. system_tray ( runtime_tray) ,
@@ -610,6 +639,15 @@ impl<R: Runtime> SystemTrayHandle<R> {
610639 self . inner . set_title ( title) . map_err ( Into :: into)
611640 }
612641
642+ /// Set the tooltip for this tray icon.
643+ ///
644+ /// ## Platform-specific:
645+ ///
646+ /// - **Linux:** Unsupported
647+ pub fn set_tooltip ( & self , tooltip : & str ) -> crate :: Result < ( ) > {
648+ self . inner . set_tooltip ( tooltip) . map_err ( Into :: into)
649+ }
650+
613651 /// Destroys this system tray.
614652 pub fn destroy ( & self ) -> crate :: Result < ( ) > {
615653 self . inner . destroy ( ) . map_err ( Into :: into)
0 commit comments